{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Introduction to DataFrames\n",
    "**[Bogumił Kamiński](http://bogumilkaminski.pl/about/), November 20, 2020**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "using DataFrames"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Getting basic information about a data frame\n",
    "\n",
    "Let's start by creating a `DataFrame` object, `x`, so that we can learn how to get information on that data frame."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table class=\"data-frame\"><thead><tr><th></th><th>A</th><th>B</th><th>C</th></tr><tr><th></th><th>Int64</th><th>Float64?</th><th>String</th></tr></thead><tbody><p>2 rows × 3 columns</p><tr><th>1</th><td>1</td><td>1.0</td><td>a</td></tr><tr><th>2</th><td>2</td><td><em>missing</em></td><td>b</td></tr></tbody></table>"
      ],
      "text/latex": [
       "\\begin{tabular}{r|ccc}\n",
       "\t& A & B & C\\\\\n",
       "\t\\hline\n",
       "\t& Int64 & Float64? & String\\\\\n",
       "\t\\hline\n",
       "\t1 & 1 & 1.0 & a \\\\\n",
       "\t2 & 2 & \\emph{missing} & b \\\\\n",
       "\\end{tabular}\n"
      ],
      "text/plain": [
       "\u001b[1m2×3 DataFrame\u001b[0m\n",
       "\u001b[1m Row \u001b[0m│\u001b[1m A     \u001b[0m\u001b[1m B         \u001b[0m\u001b[1m C      \u001b[0m\n",
       "\u001b[1m     \u001b[0m│\u001b[90m Int64 \u001b[0m\u001b[90m Float64?  \u001b[0m\u001b[90m String \u001b[0m\n",
       "─────┼──────────────────────────\n",
       "   1 │     1        1.0  a\n",
       "   2 │     2 \u001b[90m missing   \u001b[0m b"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x = DataFrame(A = [1, 2], B = [1.0, missing], C = [\"a\", \"b\"])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The standard `size` function works to get dimensions of the `DataFrame`,"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "((2, 3), 2, 3)"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "size(x), size(x, 1), size(x, 2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "as well as `nrow` and `ncol` from R."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(2, 3)"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nrow(x), ncol(x)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "`describe` gives basic summary statistics of data in your `DataFrame` (check out the help of `describe` for information on how to customize shown statistics)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table class=\"data-frame\"><thead><tr><th></th><th>variable</th><th>mean</th><th>min</th><th>median</th><th>max</th><th>nmissing</th><th>eltype</th></tr><tr><th></th><th>Symbol</th><th>Union…</th><th>Any</th><th>Union…</th><th>Any</th><th>Int64</th><th>Type</th></tr></thead><tbody><p>3 rows × 7 columns</p><tr><th>1</th><td>A</td><td>1.5</td><td>1</td><td>1.5</td><td>2</td><td>0</td><td>Int64</td></tr><tr><th>2</th><td>B</td><td>1.0</td><td>1.0</td><td>1.0</td><td>1.0</td><td>1</td><td>Union{Missing, Float64}</td></tr><tr><th>3</th><td>C</td><td></td><td>a</td><td></td><td>b</td><td>0</td><td>String</td></tr></tbody></table>"
      ],
      "text/latex": [
       "\\begin{tabular}{r|ccccccc}\n",
       "\t& variable & mean & min & median & max & nmissing & eltype\\\\\n",
       "\t\\hline\n",
       "\t& Symbol & Union… & Any & Union… & Any & Int64 & Type\\\\\n",
       "\t\\hline\n",
       "\t1 & A & 1.5 & 1 & 1.5 & 2 & 0 & Int64 \\\\\n",
       "\t2 & B & 1.0 & 1.0 & 1.0 & 1.0 & 1 & Union\\{Missing, Float64\\} \\\\\n",
       "\t3 & C &  & a &  & b & 0 & String \\\\\n",
       "\\end{tabular}\n"
      ],
      "text/plain": [
       "\u001b[1m3×7 DataFrame\u001b[0m\n",
       "\u001b[1m Row \u001b[0m│\u001b[1m variable \u001b[0m\u001b[1m mean   \u001b[0m\u001b[1m min \u001b[0m\u001b[1m median \u001b[0m\u001b[1m max \u001b[0m\u001b[1m nmissing \u001b[0m\u001b[1m eltype                  \u001b[0m\n",
       "\u001b[1m     \u001b[0m│\u001b[90m Symbol   \u001b[0m\u001b[90m Union… \u001b[0m\u001b[90m Any \u001b[0m\u001b[90m Union… \u001b[0m\u001b[90m Any \u001b[0m\u001b[90m Int64    \u001b[0m\u001b[90m Type                    \u001b[0m\n",
       "─────┼───────────────────────────────────────────────────────────────────────\n",
       "   1 │ A         1.5     1    1.5     2           0  Int64\n",
       "   2 │ B         1.0     1.0  1.0     1.0         1  Union{Missing, Float64}\n",
       "   3 │ C        \u001b[90m        \u001b[0m a   \u001b[90m        \u001b[0m b           0  String"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "describe(x)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "you can limit the columns shown by `describe` using `cols` keyword argument"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table class=\"data-frame\"><thead><tr><th></th><th>variable</th><th>mean</th><th>min</th><th>median</th><th>max</th><th>nmissing</th><th>eltype</th></tr><tr><th></th><th>Symbol</th><th>Float64</th><th>Real</th><th>Float64</th><th>Real</th><th>Int64</th><th>Type</th></tr></thead><tbody><p>2 rows × 7 columns</p><tr><th>1</th><td>A</td><td>1.5</td><td>1</td><td>1.5</td><td>2</td><td>0</td><td>Int64</td></tr><tr><th>2</th><td>B</td><td>1.0</td><td>1.0</td><td>1.0</td><td>1.0</td><td>1</td><td>Union{Missing, Float64}</td></tr></tbody></table>"
      ],
      "text/latex": [
       "\\begin{tabular}{r|ccccccc}\n",
       "\t& variable & mean & min & median & max & nmissing & eltype\\\\\n",
       "\t\\hline\n",
       "\t& Symbol & Float64 & Real & Float64 & Real & Int64 & Type\\\\\n",
       "\t\\hline\n",
       "\t1 & A & 1.5 & 1 & 1.5 & 2 & 0 & Int64 \\\\\n",
       "\t2 & B & 1.0 & 1.0 & 1.0 & 1.0 & 1 & Union\\{Missing, Float64\\} \\\\\n",
       "\\end{tabular}\n"
      ],
      "text/plain": [
       "\u001b[1m2×7 DataFrame\u001b[0m\n",
       "\u001b[1m Row \u001b[0m│\u001b[1m variable \u001b[0m\u001b[1m mean    \u001b[0m\u001b[1m min  \u001b[0m\u001b[1m median  \u001b[0m\u001b[1m max  \u001b[0m\u001b[1m nmissing \u001b[0m\u001b[1m eltype               \u001b[0m ⋯\n",
       "\u001b[1m     \u001b[0m│\u001b[90m Symbol   \u001b[0m\u001b[90m Float64 \u001b[0m\u001b[90m Real \u001b[0m\u001b[90m Float64 \u001b[0m\u001b[90m Real \u001b[0m\u001b[90m Int64    \u001b[0m\u001b[90m Type                 \u001b[0m ⋯\n",
       "─────┼──────────────────────────────────────────────────────────────────────────\n",
       "   1 │ A             1.5     1      1.5     2         0  Int64                 ⋯\n",
       "   2 │ B             1.0   1.0      1.0   1.0         1  Union{Missing, Float6\n",
       "\u001b[31m                                                                1 column omitted\u001b[0m"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "describe(x, cols=1:2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "`names` will return the names of all columns as strings"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3-element Array{String,1}:\n",
       " \"A\"\n",
       " \"B\"\n",
       " \"C\""
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names(x)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "you can also get column names with a given `eltype`:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1-element Array{String,1}:\n",
       " \"C\""
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names(x, String)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "use `propertynames` to get a vector of `Symbol`s:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3-element Array{Symbol,1}:\n",
       " :A\n",
       " :B\n",
       " :C"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "propertynames(x)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "using `eltype` on `eachcol(x)` returns element types of columns:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3-element Array{Type,1}:\n",
       " Int64\n",
       " Union{Missing, Float64}\n",
       " String"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "eltype.(eachcol(x))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Here we create some large `DataFrame`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table class=\"data-frame\"><thead><tr><th></th><th>x1</th><th>x2</th><th>x3</th><th>x4</th><th>x5</th><th>x6</th><th>x7</th><th>x8</th><th>x9</th><th>x10</th></tr><tr><th></th><th>Int64</th><th>Int64</th><th>Int64</th><th>Int64</th><th>Int64</th><th>Int64</th><th>Int64</th><th>Int64</th><th>Int64</th><th>Int64</th></tr></thead><tbody><p>1,000 rows × 10 columns</p><tr><th>1</th><td>5</td><td>9</td><td>3</td><td>2</td><td>8</td><td>8</td><td>8</td><td>3</td><td>8</td><td>1</td></tr><tr><th>2</th><td>4</td><td>10</td><td>3</td><td>7</td><td>1</td><td>4</td><td>5</td><td>6</td><td>8</td><td>5</td></tr><tr><th>3</th><td>10</td><td>4</td><td>1</td><td>4</td><td>4</td><td>3</td><td>9</td><td>1</td><td>2</td><td>9</td></tr><tr><th>4</th><td>10</td><td>10</td><td>4</td><td>3</td><td>3</td><td>3</td><td>4</td><td>5</td><td>1</td><td>2</td></tr><tr><th>5</th><td>4</td><td>5</td><td>5</td><td>4</td><td>1</td><td>1</td><td>6</td><td>1</td><td>8</td><td>4</td></tr><tr><th>6</th><td>10</td><td>9</td><td>2</td><td>1</td><td>1</td><td>9</td><td>10</td><td>6</td><td>3</td><td>7</td></tr><tr><th>7</th><td>1</td><td>6</td><td>6</td><td>9</td><td>3</td><td>9</td><td>6</td><td>6</td><td>7</td><td>8</td></tr><tr><th>8</th><td>7</td><td>9</td><td>3</td><td>4</td><td>4</td><td>2</td><td>1</td><td>9</td><td>6</td><td>4</td></tr><tr><th>9</th><td>10</td><td>3</td><td>7</td><td>10</td><td>5</td><td>8</td><td>9</td><td>9</td><td>4</td><td>2</td></tr><tr><th>10</th><td>7</td><td>3</td><td>2</td><td>10</td><td>10</td><td>2</td><td>2</td><td>4</td><td>2</td><td>6</td></tr><tr><th>11</th><td>4</td><td>1</td><td>10</td><td>7</td><td>6</td><td>1</td><td>6</td><td>3</td><td>8</td><td>6</td></tr><tr><th>12</th><td>10</td><td>1</td><td>7</td><td>4</td><td>8</td><td>10</td><td>5</td><td>4</td><td>10</td><td>6</td></tr><tr><th>13</th><td>5</td><td>8</td><td>10</td><td>1</td><td>3</td><td>8</td><td>10</td><td>10</td><td>10</td><td>4</td></tr><tr><th>14</th><td>6</td><td>4</td><td>8</td><td>8</td><td>9</td><td>7</td><td>6</td><td>10</td><td>5</td><td>10</td></tr><tr><th>15</th><td>7</td><td>5</td><td>9</td><td>3</td><td>3</td><td>3</td><td>8</td><td>8</td><td>3</td><td>6</td></tr><tr><th>16</th><td>3</td><td>1</td><td>1</td><td>3</td><td>10</td><td>1</td><td>6</td><td>10</td><td>4</td><td>5</td></tr><tr><th>17</th><td>10</td><td>10</td><td>4</td><td>3</td><td>9</td><td>3</td><td>1</td><td>7</td><td>6</td><td>7</td></tr><tr><th>18</th><td>3</td><td>9</td><td>7</td><td>7</td><td>2</td><td>8</td><td>6</td><td>5</td><td>1</td><td>8</td></tr><tr><th>19</th><td>4</td><td>7</td><td>2</td><td>8</td><td>10</td><td>7</td><td>4</td><td>2</td><td>3</td><td>7</td></tr><tr><th>20</th><td>5</td><td>8</td><td>10</td><td>1</td><td>4</td><td>5</td><td>5</td><td>2</td><td>1</td><td>3</td></tr><tr><th>21</th><td>9</td><td>9</td><td>4</td><td>3</td><td>2</td><td>3</td><td>6</td><td>6</td><td>4</td><td>3</td></tr><tr><th>22</th><td>6</td><td>9</td><td>4</td><td>3</td><td>1</td><td>3</td><td>5</td><td>5</td><td>10</td><td>8</td></tr><tr><th>23</th><td>10</td><td>5</td><td>5</td><td>4</td><td>5</td><td>3</td><td>9</td><td>10</td><td>1</td><td>1</td></tr><tr><th>24</th><td>5</td><td>10</td><td>3</td><td>2</td><td>7</td><td>2</td><td>3</td><td>1</td><td>1</td><td>5</td></tr><tr><th>25</th><td>5</td><td>1</td><td>4</td><td>7</td><td>9</td><td>2</td><td>3</td><td>1</td><td>8</td><td>8</td></tr><tr><th>26</th><td>2</td><td>3</td><td>10</td><td>4</td><td>6</td><td>9</td><td>8</td><td>10</td><td>2</td><td>8</td></tr><tr><th>27</th><td>1</td><td>7</td><td>2</td><td>6</td><td>9</td><td>9</td><td>4</td><td>3</td><td>5</td><td>6</td></tr><tr><th>28</th><td>4</td><td>10</td><td>9</td><td>7</td><td>2</td><td>5</td><td>9</td><td>2</td><td>10</td><td>1</td></tr><tr><th>29</th><td>2</td><td>1</td><td>4</td><td>5</td><td>9</td><td>10</td><td>5</td><td>10</td><td>6</td><td>10</td></tr><tr><th>30</th><td>4</td><td>7</td><td>8</td><td>3</td><td>3</td><td>4</td><td>9</td><td>8</td><td>2</td><td>1</td></tr><tr><th>&vellip;</th><td>&vellip;</td><td>&vellip;</td><td>&vellip;</td><td>&vellip;</td><td>&vellip;</td><td>&vellip;</td><td>&vellip;</td><td>&vellip;</td><td>&vellip;</td><td>&vellip;</td></tr></tbody></table>"
      ],
      "text/latex": [
       "\\begin{tabular}{r|cccccccccc}\n",
       "\t& x1 & x2 & x3 & x4 & x5 & x6 & x7 & x8 & x9 & x10\\\\\n",
       "\t\\hline\n",
       "\t& Int64 & Int64 & Int64 & Int64 & Int64 & Int64 & Int64 & Int64 & Int64 & Int64\\\\\n",
       "\t\\hline\n",
       "\t1 & 5 & 9 & 3 & 2 & 8 & 8 & 8 & 3 & 8 & 1 \\\\\n",
       "\t2 & 4 & 10 & 3 & 7 & 1 & 4 & 5 & 6 & 8 & 5 \\\\\n",
       "\t3 & 10 & 4 & 1 & 4 & 4 & 3 & 9 & 1 & 2 & 9 \\\\\n",
       "\t4 & 10 & 10 & 4 & 3 & 3 & 3 & 4 & 5 & 1 & 2 \\\\\n",
       "\t5 & 4 & 5 & 5 & 4 & 1 & 1 & 6 & 1 & 8 & 4 \\\\\n",
       "\t6 & 10 & 9 & 2 & 1 & 1 & 9 & 10 & 6 & 3 & 7 \\\\\n",
       "\t7 & 1 & 6 & 6 & 9 & 3 & 9 & 6 & 6 & 7 & 8 \\\\\n",
       "\t8 & 7 & 9 & 3 & 4 & 4 & 2 & 1 & 9 & 6 & 4 \\\\\n",
       "\t9 & 10 & 3 & 7 & 10 & 5 & 8 & 9 & 9 & 4 & 2 \\\\\n",
       "\t10 & 7 & 3 & 2 & 10 & 10 & 2 & 2 & 4 & 2 & 6 \\\\\n",
       "\t11 & 4 & 1 & 10 & 7 & 6 & 1 & 6 & 3 & 8 & 6 \\\\\n",
       "\t12 & 10 & 1 & 7 & 4 & 8 & 10 & 5 & 4 & 10 & 6 \\\\\n",
       "\t13 & 5 & 8 & 10 & 1 & 3 & 8 & 10 & 10 & 10 & 4 \\\\\n",
       "\t14 & 6 & 4 & 8 & 8 & 9 & 7 & 6 & 10 & 5 & 10 \\\\\n",
       "\t15 & 7 & 5 & 9 & 3 & 3 & 3 & 8 & 8 & 3 & 6 \\\\\n",
       "\t16 & 3 & 1 & 1 & 3 & 10 & 1 & 6 & 10 & 4 & 5 \\\\\n",
       "\t17 & 10 & 10 & 4 & 3 & 9 & 3 & 1 & 7 & 6 & 7 \\\\\n",
       "\t18 & 3 & 9 & 7 & 7 & 2 & 8 & 6 & 5 & 1 & 8 \\\\\n",
       "\t19 & 4 & 7 & 2 & 8 & 10 & 7 & 4 & 2 & 3 & 7 \\\\\n",
       "\t20 & 5 & 8 & 10 & 1 & 4 & 5 & 5 & 2 & 1 & 3 \\\\\n",
       "\t21 & 9 & 9 & 4 & 3 & 2 & 3 & 6 & 6 & 4 & 3 \\\\\n",
       "\t22 & 6 & 9 & 4 & 3 & 1 & 3 & 5 & 5 & 10 & 8 \\\\\n",
       "\t23 & 10 & 5 & 5 & 4 & 5 & 3 & 9 & 10 & 1 & 1 \\\\\n",
       "\t24 & 5 & 10 & 3 & 2 & 7 & 2 & 3 & 1 & 1 & 5 \\\\\n",
       "\t25 & 5 & 1 & 4 & 7 & 9 & 2 & 3 & 1 & 8 & 8 \\\\\n",
       "\t26 & 2 & 3 & 10 & 4 & 6 & 9 & 8 & 10 & 2 & 8 \\\\\n",
       "\t27 & 1 & 7 & 2 & 6 & 9 & 9 & 4 & 3 & 5 & 6 \\\\\n",
       "\t28 & 4 & 10 & 9 & 7 & 2 & 5 & 9 & 2 & 10 & 1 \\\\\n",
       "\t29 & 2 & 1 & 4 & 5 & 9 & 10 & 5 & 10 & 6 & 10 \\\\\n",
       "\t30 & 4 & 7 & 8 & 3 & 3 & 4 & 9 & 8 & 2 & 1 \\\\\n",
       "\t$\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ \\\\\n",
       "\\end{tabular}\n"
      ],
      "text/plain": [
       "\u001b[1m1000×10 DataFrame\u001b[0m\n",
       "\u001b[1m  Row \u001b[0m│\u001b[1m x1    \u001b[0m\u001b[1m x2    \u001b[0m\u001b[1m x3    \u001b[0m\u001b[1m x4    \u001b[0m\u001b[1m x5    \u001b[0m\u001b[1m x6    \u001b[0m\u001b[1m x7    \u001b[0m\u001b[1m x8    \u001b[0m\u001b[1m x9    \u001b[0m\u001b[1m x10   \u001b[0m\n",
       "\u001b[1m      \u001b[0m│\u001b[90m Int64 \u001b[0m\u001b[90m Int64 \u001b[0m\u001b[90m Int64 \u001b[0m\u001b[90m Int64 \u001b[0m\u001b[90m Int64 \u001b[0m\u001b[90m Int64 \u001b[0m\u001b[90m Int64 \u001b[0m\u001b[90m Int64 \u001b[0m\u001b[90m Int64 \u001b[0m\u001b[90m Int64 \u001b[0m\n",
       "──────┼──────────────────────────────────────────────────────────────────────\n",
       "    1 │     5      9      3      2      8      8      8      3  8      1\n",
       "    2 │     4     10      3      7      1      4      5      6  8      5\n",
       "    3 │    10      4      1      4      4      3      9      1  2      9\n",
       "    4 │    10     10      4      3      3      3      4      5  1      2\n",
       "    5 │     4      5      5      4      1      1      6      1  8      4\n",
       "    6 │    10      9      2      1      1      9     10      6  3      7\n",
       "    7 │     1      6      6      9      3      9      6      6  7      8\n",
       "    8 │     7      9      3      4      4      2      1      9  6      4\n",
       "    9 │    10      3      7     10      5      8      9      9  4      2\n",
       "   10 │     7      3      2     10     10      2      2      4  2      6\n",
       "   11 │     4      1     10      7      6      1      6      3  8      6\n",
       "  ⋮   │   ⋮      ⋮      ⋮      ⋮      ⋮      ⋮      ⋮      ⋮      ⋮      ⋮\n",
       "  991 │     3      8      8      9     10      4      1      5  5      7\n",
       "  992 │     5      2      3      3      5      5      2      5  4      6\n",
       "  993 │     9     10      7      2      5      6      9      8  3      10\n",
       "  994 │     5      3      1      6     10      2     10      3  4      9\n",
       "  995 │     1      3      1      5      1      9      4      2  7      8\n",
       "  996 │     3     10      7      7      5      4      8      1  9      3\n",
       "  997 │    10      9      8      5      6      9      8      7  6      2\n",
       "  998 │     8      1      1     10      3      7      1      2  6      9\n",
       "  999 │     2      8      9      3      3      7      5      5  4      9\n",
       " 1000 │     8      6      4      1      5      9      5      9  3      5\n",
       "\u001b[31m                                                             979 rows omitted\u001b[0m"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y = DataFrame(rand(1:10, 1000, 10), :auto)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "and then we can use `first` to peek into its first few rows"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table class=\"data-frame\"><thead><tr><th></th><th>x1</th><th>x2</th><th>x3</th><th>x4</th><th>x5</th><th>x6</th><th>x7</th><th>x8</th><th>x9</th><th>x10</th></tr><tr><th></th><th>Int64</th><th>Int64</th><th>Int64</th><th>Int64</th><th>Int64</th><th>Int64</th><th>Int64</th><th>Int64</th><th>Int64</th><th>Int64</th></tr></thead><tbody><p>5 rows × 10 columns</p><tr><th>1</th><td>5</td><td>9</td><td>3</td><td>2</td><td>8</td><td>8</td><td>8</td><td>3</td><td>8</td><td>1</td></tr><tr><th>2</th><td>4</td><td>10</td><td>3</td><td>7</td><td>1</td><td>4</td><td>5</td><td>6</td><td>8</td><td>5</td></tr><tr><th>3</th><td>10</td><td>4</td><td>1</td><td>4</td><td>4</td><td>3</td><td>9</td><td>1</td><td>2</td><td>9</td></tr><tr><th>4</th><td>10</td><td>10</td><td>4</td><td>3</td><td>3</td><td>3</td><td>4</td><td>5</td><td>1</td><td>2</td></tr><tr><th>5</th><td>4</td><td>5</td><td>5</td><td>4</td><td>1</td><td>1</td><td>6</td><td>1</td><td>8</td><td>4</td></tr></tbody></table>"
      ],
      "text/latex": [
       "\\begin{tabular}{r|cccccccccc}\n",
       "\t& x1 & x2 & x3 & x4 & x5 & x6 & x7 & x8 & x9 & x10\\\\\n",
       "\t\\hline\n",
       "\t& Int64 & Int64 & Int64 & Int64 & Int64 & Int64 & Int64 & Int64 & Int64 & Int64\\\\\n",
       "\t\\hline\n",
       "\t1 & 5 & 9 & 3 & 2 & 8 & 8 & 8 & 3 & 8 & 1 \\\\\n",
       "\t2 & 4 & 10 & 3 & 7 & 1 & 4 & 5 & 6 & 8 & 5 \\\\\n",
       "\t3 & 10 & 4 & 1 & 4 & 4 & 3 & 9 & 1 & 2 & 9 \\\\\n",
       "\t4 & 10 & 10 & 4 & 3 & 3 & 3 & 4 & 5 & 1 & 2 \\\\\n",
       "\t5 & 4 & 5 & 5 & 4 & 1 & 1 & 6 & 1 & 8 & 4 \\\\\n",
       "\\end{tabular}\n"
      ],
      "text/plain": [
       "\u001b[1m5×10 DataFrame\u001b[0m\n",
       "\u001b[1m Row \u001b[0m│\u001b[1m x1    \u001b[0m\u001b[1m x2    \u001b[0m\u001b[1m x3    \u001b[0m\u001b[1m x4    \u001b[0m\u001b[1m x5    \u001b[0m\u001b[1m x6    \u001b[0m\u001b[1m x7    \u001b[0m\u001b[1m x8    \u001b[0m\u001b[1m x9    \u001b[0m\u001b[1m x10   \u001b[0m\n",
       "\u001b[1m     \u001b[0m│\u001b[90m Int64 \u001b[0m\u001b[90m Int64 \u001b[0m\u001b[90m Int64 \u001b[0m\u001b[90m Int64 \u001b[0m\u001b[90m Int64 \u001b[0m\u001b[90m Int64 \u001b[0m\u001b[90m Int64 \u001b[0m\u001b[90m Int64 \u001b[0m\u001b[90m Int64 \u001b[0m\u001b[90m Int64 \u001b[0m\n",
       "─────┼──────────────────────────────────────────────────────────────────────\n",
       "   1 │     5      9      3      2      8      8      8      3  8      1\n",
       "   2 │     4     10      3      7      1      4      5      6  8      5\n",
       "   3 │    10      4      1      4      4      3      9      1  2      9\n",
       "   4 │    10     10      4      3      3      3      4      5  1      2\n",
       "   5 │     4      5      5      4      1      1      6      1  8      4"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "first(y, 5)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "and `last` to see its bottom rows."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table class=\"data-frame\"><thead><tr><th></th><th>x1</th><th>x2</th><th>x3</th><th>x4</th><th>x5</th><th>x6</th><th>x7</th><th>x8</th><th>x9</th><th>x10</th></tr><tr><th></th><th>Int64</th><th>Int64</th><th>Int64</th><th>Int64</th><th>Int64</th><th>Int64</th><th>Int64</th><th>Int64</th><th>Int64</th><th>Int64</th></tr></thead><tbody><p>3 rows × 10 columns</p><tr><th>1</th><td>8</td><td>1</td><td>1</td><td>10</td><td>3</td><td>7</td><td>1</td><td>2</td><td>6</td><td>9</td></tr><tr><th>2</th><td>2</td><td>8</td><td>9</td><td>3</td><td>3</td><td>7</td><td>5</td><td>5</td><td>4</td><td>9</td></tr><tr><th>3</th><td>8</td><td>6</td><td>4</td><td>1</td><td>5</td><td>9</td><td>5</td><td>9</td><td>3</td><td>5</td></tr></tbody></table>"
      ],
      "text/latex": [
       "\\begin{tabular}{r|cccccccccc}\n",
       "\t& x1 & x2 & x3 & x4 & x5 & x6 & x7 & x8 & x9 & x10\\\\\n",
       "\t\\hline\n",
       "\t& Int64 & Int64 & Int64 & Int64 & Int64 & Int64 & Int64 & Int64 & Int64 & Int64\\\\\n",
       "\t\\hline\n",
       "\t1 & 8 & 1 & 1 & 10 & 3 & 7 & 1 & 2 & 6 & 9 \\\\\n",
       "\t2 & 2 & 8 & 9 & 3 & 3 & 7 & 5 & 5 & 4 & 9 \\\\\n",
       "\t3 & 8 & 6 & 4 & 1 & 5 & 9 & 5 & 9 & 3 & 5 \\\\\n",
       "\\end{tabular}\n"
      ],
      "text/plain": [
       "\u001b[1m3×10 DataFrame\u001b[0m\n",
       "\u001b[1m Row \u001b[0m│\u001b[1m x1    \u001b[0m\u001b[1m x2    \u001b[0m\u001b[1m x3    \u001b[0m\u001b[1m x4    \u001b[0m\u001b[1m x5    \u001b[0m\u001b[1m x6    \u001b[0m\u001b[1m x7    \u001b[0m\u001b[1m x8    \u001b[0m\u001b[1m x9    \u001b[0m\u001b[1m x10   \u001b[0m\n",
       "\u001b[1m     \u001b[0m│\u001b[90m Int64 \u001b[0m\u001b[90m Int64 \u001b[0m\u001b[90m Int64 \u001b[0m\u001b[90m Int64 \u001b[0m\u001b[90m Int64 \u001b[0m\u001b[90m Int64 \u001b[0m\u001b[90m Int64 \u001b[0m\u001b[90m Int64 \u001b[0m\u001b[90m Int64 \u001b[0m\u001b[90m Int64 \u001b[0m\n",
       "─────┼──────────────────────────────────────────────────────────────────────\n",
       "   1 │     8      1      1     10      3      7      1      2  6      9\n",
       "   2 │     2      8      9      3      3      7      5      5  4      9\n",
       "   3 │     8      6      4      1      5      9      5      9  3      5"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "last(y, 3)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Using `first` and `last` without number of rows will return a first/last `DataFrameRow` in the `DataFrame`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<p>DataFrameRow (10 columns)</p><table class=\"data-frame\"><thead><tr><th></th><th>x1</th><th>x2</th><th>x3</th><th>x4</th><th>x5</th><th>x6</th><th>x7</th><th>x8</th><th>x9</th><th>x10</th></tr><tr><th></th><th>Int64</th><th>Int64</th><th>Int64</th><th>Int64</th><th>Int64</th><th>Int64</th><th>Int64</th><th>Int64</th><th>Int64</th><th>Int64</th></tr></thead><tbody><tr><th>1</th><td>5</td><td>9</td><td>3</td><td>2</td><td>8</td><td>8</td><td>8</td><td>3</td><td>8</td><td>1</td></tr></tbody></table>"
      ],
      "text/latex": [
       "\\begin{tabular}{r|cccccccccc}\n",
       "\t& x1 & x2 & x3 & x4 & x5 & x6 & x7 & x8 & x9 & x10\\\\\n",
       "\t\\hline\n",
       "\t& Int64 & Int64 & Int64 & Int64 & Int64 & Int64 & Int64 & Int64 & Int64 & Int64\\\\\n",
       "\t\\hline\n",
       "\t1 & 5 & 9 & 3 & 2 & 8 & 8 & 8 & 3 & 8 & 1 \\\\\n",
       "\\end{tabular}\n"
      ],
      "text/plain": [
       "\u001b[1mDataFrameRow\u001b[0m\n",
       "\u001b[1m Row \u001b[0m│\u001b[1m x1    \u001b[0m\u001b[1m x2    \u001b[0m\u001b[1m x3    \u001b[0m\u001b[1m x4    \u001b[0m\u001b[1m x5    \u001b[0m\u001b[1m x6    \u001b[0m\u001b[1m x7    \u001b[0m\u001b[1m x8    \u001b[0m\u001b[1m x9    \u001b[0m\u001b[1m x10   \u001b[0m\n",
       "\u001b[1m     \u001b[0m│\u001b[90m Int64 \u001b[0m\u001b[90m Int64 \u001b[0m\u001b[90m Int64 \u001b[0m\u001b[90m Int64 \u001b[0m\u001b[90m Int64 \u001b[0m\u001b[90m Int64 \u001b[0m\u001b[90m Int64 \u001b[0m\u001b[90m Int64 \u001b[0m\u001b[90m Int64 \u001b[0m\u001b[90m Int64 \u001b[0m\n",
       "─────┼──────────────────────────────────────────────────────────────────────\n",
       "   1 │     5      9      3      2      8      8      8      3  8      1"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "first(y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<p>DataFrameRow (10 columns)</p><table class=\"data-frame\"><thead><tr><th></th><th>x1</th><th>x2</th><th>x3</th><th>x4</th><th>x5</th><th>x6</th><th>x7</th><th>x8</th><th>x9</th><th>x10</th></tr><tr><th></th><th>Int64</th><th>Int64</th><th>Int64</th><th>Int64</th><th>Int64</th><th>Int64</th><th>Int64</th><th>Int64</th><th>Int64</th><th>Int64</th></tr></thead><tbody><tr><th>1000</th><td>8</td><td>6</td><td>4</td><td>1</td><td>5</td><td>9</td><td>5</td><td>9</td><td>3</td><td>5</td></tr></tbody></table>"
      ],
      "text/latex": [
       "\\begin{tabular}{r|cccccccccc}\n",
       "\t& x1 & x2 & x3 & x4 & x5 & x6 & x7 & x8 & x9 & x10\\\\\n",
       "\t\\hline\n",
       "\t& Int64 & Int64 & Int64 & Int64 & Int64 & Int64 & Int64 & Int64 & Int64 & Int64\\\\\n",
       "\t\\hline\n",
       "\t1000 & 8 & 6 & 4 & 1 & 5 & 9 & 5 & 9 & 3 & 5 \\\\\n",
       "\\end{tabular}\n"
      ],
      "text/plain": [
       "\u001b[1mDataFrameRow\u001b[0m\n",
       "\u001b[1m  Row \u001b[0m│\u001b[1m x1    \u001b[0m\u001b[1m x2    \u001b[0m\u001b[1m x3    \u001b[0m\u001b[1m x4    \u001b[0m\u001b[1m x5    \u001b[0m\u001b[1m x6    \u001b[0m\u001b[1m x7    \u001b[0m\u001b[1m x8    \u001b[0m\u001b[1m x9    \u001b[0m\u001b[1m x10   \u001b[0m\n",
       "\u001b[1m      \u001b[0m│\u001b[90m Int64 \u001b[0m\u001b[90m Int64 \u001b[0m\u001b[90m Int64 \u001b[0m\u001b[90m Int64 \u001b[0m\u001b[90m Int64 \u001b[0m\u001b[90m Int64 \u001b[0m\u001b[90m Int64 \u001b[0m\u001b[90m Int64 \u001b[0m\u001b[90m Int64 \u001b[0m\u001b[90m Int64 \u001b[0m\n",
       "──────┼──────────────────────────────────────────────────────────────────────\n",
       " 1000 │     8      6      4      1      5      9      5      9  3      5"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "last(y)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Displaying large data frames"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Create a wide and tall data frame:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table class=\"data-frame\"><thead><tr><th></th><th>x1</th><th>x2</th><th>x3</th><th>x4</th><th>x5</th><th>x6</th><th>x7</th><th>x8</th></tr><tr><th></th><th>Float64</th><th>Float64</th><th>Float64</th><th>Float64</th><th>Float64</th><th>Float64</th><th>Float64</th><th>Float64</th></tr></thead><tbody><p>100 rows × 100 columns (omitted printing of 92 columns)</p><tr><th>1</th><td>0.0407606</td><td>0.117232</td><td>0.348204</td><td>0.269438</td><td>0.452216</td><td>0.31456</td><td>0.677597</td><td>0.719277</td></tr><tr><th>2</th><td>0.376506</td><td>0.482919</td><td>0.669578</td><td>0.43432</td><td>0.975168</td><td>0.03292</td><td>0.181948</td><td>0.232741</td></tr><tr><th>3</th><td>0.753126</td><td>0.00911066</td><td>0.991773</td><td>0.296264</td><td>0.270301</td><td>0.0932391</td><td>0.494824</td><td>0.97819</td></tr><tr><th>4</th><td>0.814347</td><td>0.312632</td><td>0.805042</td><td>0.545419</td><td>0.169538</td><td>0.688139</td><td>0.600611</td><td>0.591047</td></tr><tr><th>5</th><td>0.584648</td><td>0.449159</td><td>0.781232</td><td>0.704917</td><td>0.401786</td><td>0.262193</td><td>0.763988</td><td>0.114793</td></tr><tr><th>6</th><td>0.557345</td><td>0.106035</td><td>0.788548</td><td>0.216535</td><td>0.678853</td><td>0.572301</td><td>0.231112</td><td>0.367835</td></tr><tr><th>7</th><td>0.29653</td><td>0.932721</td><td>0.316042</td><td>0.667673</td><td>0.66609</td><td>0.0961946</td><td>0.837986</td><td>0.901083</td></tr><tr><th>8</th><td>0.0647716</td><td>0.423136</td><td>0.449464</td><td>0.0786289</td><td>0.114109</td><td>0.186914</td><td>0.321308</td><td>0.212699</td></tr><tr><th>9</th><td>0.650907</td><td>0.443851</td><td>0.433511</td><td>0.0636988</td><td>0.153576</td><td>0.919171</td><td>0.140223</td><td>0.0825558</td></tr><tr><th>10</th><td>0.958762</td><td>0.368439</td><td>0.0191283</td><td>0.717186</td><td>0.0771803</td><td>0.386313</td><td>0.05567</td><td>0.574292</td></tr><tr><th>11</th><td>0.0630877</td><td>0.834178</td><td>0.904894</td><td>0.483445</td><td>0.393452</td><td>0.937474</td><td>0.802854</td><td>0.844619</td></tr><tr><th>12</th><td>0.65562</td><td>0.733142</td><td>0.671057</td><td>0.355558</td><td>0.246691</td><td>0.775784</td><td>0.619014</td><td>0.18217</td></tr><tr><th>13</th><td>0.946392</td><td>0.695418</td><td>0.516211</td><td>0.486641</td><td>0.310322</td><td>0.307265</td><td>0.938915</td><td>0.250204</td></tr><tr><th>14</th><td>0.503955</td><td>0.589702</td><td>0.616751</td><td>0.945406</td><td>0.877692</td><td>0.206424</td><td>0.91199</td><td>0.893462</td></tr><tr><th>15</th><td>0.499284</td><td>0.311172</td><td>0.0956649</td><td>0.979099</td><td>0.811256</td><td>0.618866</td><td>0.630661</td><td>0.0858452</td></tr><tr><th>16</th><td>0.978203</td><td>0.734465</td><td>0.284393</td><td>0.44849</td><td>0.618191</td><td>0.0564206</td><td>0.661726</td><td>0.385878</td></tr><tr><th>17</th><td>0.229373</td><td>0.0927034</td><td>0.888742</td><td>0.31831</td><td>0.317461</td><td>0.79476</td><td>0.841271</td><td>0.732834</td></tr><tr><th>18</th><td>0.513956</td><td>0.307635</td><td>0.0249502</td><td>0.916705</td><td>0.8457</td><td>0.167388</td><td>0.916269</td><td>0.299036</td></tr><tr><th>19</th><td>0.861957</td><td>0.967549</td><td>0.934819</td><td>0.108393</td><td>0.464308</td><td>0.419042</td><td>0.219305</td><td>0.174648</td></tr><tr><th>20</th><td>0.00664397</td><td>0.901527</td><td>0.827246</td><td>0.627196</td><td>0.0764198</td><td>0.820422</td><td>0.565004</td><td>0.49255</td></tr><tr><th>21</th><td>0.390871</td><td>0.801431</td><td>0.918931</td><td>0.0979271</td><td>0.592743</td><td>0.303345</td><td>0.313241</td><td>0.851179</td></tr><tr><th>22</th><td>0.156969</td><td>0.495174</td><td>0.157765</td><td>0.0894507</td><td>0.109911</td><td>0.755358</td><td>0.0743305</td><td>0.60423</td></tr><tr><th>23</th><td>0.839897</td><td>0.383783</td><td>0.756021</td><td>0.396748</td><td>0.655357</td><td>0.582485</td><td>0.87436</td><td>0.981817</td></tr><tr><th>24</th><td>0.74222</td><td>0.738414</td><td>0.618398</td><td>0.340952</td><td>0.876249</td><td>0.240001</td><td>0.481201</td><td>0.786258</td></tr><tr><th>25</th><td>0.419736</td><td>0.232224</td><td>0.0399255</td><td>0.113019</td><td>0.313992</td><td>0.0122699</td><td>0.660767</td><td>0.137172</td></tr><tr><th>26</th><td>0.755163</td><td>0.151577</td><td>0.775046</td><td>0.930667</td><td>0.684634</td><td>0.735555</td><td>0.296639</td><td>0.394769</td></tr><tr><th>27</th><td>0.0882264</td><td>0.45015</td><td>0.0226739</td><td>0.097282</td><td>0.584313</td><td>0.0960262</td><td>0.741087</td><td>0.970699</td></tr><tr><th>28</th><td>0.145551</td><td>0.978237</td><td>0.615475</td><td>0.746586</td><td>0.744925</td><td>0.60964</td><td>0.351659</td><td>0.997235</td></tr><tr><th>29</th><td>0.792067</td><td>0.424946</td><td>0.372801</td><td>0.32207</td><td>0.596983</td><td>0.504858</td><td>0.798345</td><td>0.0965333</td></tr><tr><th>30</th><td>0.147033</td><td>0.386304</td><td>0.010448</td><td>0.98077</td><td>0.410856</td><td>0.337126</td><td>0.440139</td><td>0.0756289</td></tr><tr><th>&vellip;</th><td>&vellip;</td><td>&vellip;</td><td>&vellip;</td><td>&vellip;</td><td>&vellip;</td><td>&vellip;</td><td>&vellip;</td><td>&vellip;</td></tr></tbody></table>"
      ],
      "text/latex": [
       "\\begin{tabular}{r|ccccccccc}\n",
       "\t& x1 & x2 & x3 & x4 & x5 & x6 & x7 & x8 & \\\\\n",
       "\t\\hline\n",
       "\t& Float64 & Float64 & Float64 & Float64 & Float64 & Float64 & Float64 & Float64 & \\\\\n",
       "\t\\hline\n",
       "\t1 & 0.0407606 & 0.117232 & 0.348204 & 0.269438 & 0.452216 & 0.31456 & 0.677597 & 0.719277 & $\\dots$ \\\\\n",
       "\t2 & 0.376506 & 0.482919 & 0.669578 & 0.43432 & 0.975168 & 0.03292 & 0.181948 & 0.232741 & $\\dots$ \\\\\n",
       "\t3 & 0.753126 & 0.00911066 & 0.991773 & 0.296264 & 0.270301 & 0.0932391 & 0.494824 & 0.97819 & $\\dots$ \\\\\n",
       "\t4 & 0.814347 & 0.312632 & 0.805042 & 0.545419 & 0.169538 & 0.688139 & 0.600611 & 0.591047 & $\\dots$ \\\\\n",
       "\t5 & 0.584648 & 0.449159 & 0.781232 & 0.704917 & 0.401786 & 0.262193 & 0.763988 & 0.114793 & $\\dots$ \\\\\n",
       "\t6 & 0.557345 & 0.106035 & 0.788548 & 0.216535 & 0.678853 & 0.572301 & 0.231112 & 0.367835 & $\\dots$ \\\\\n",
       "\t7 & 0.29653 & 0.932721 & 0.316042 & 0.667673 & 0.66609 & 0.0961946 & 0.837986 & 0.901083 & $\\dots$ \\\\\n",
       "\t8 & 0.0647716 & 0.423136 & 0.449464 & 0.0786289 & 0.114109 & 0.186914 & 0.321308 & 0.212699 & $\\dots$ \\\\\n",
       "\t9 & 0.650907 & 0.443851 & 0.433511 & 0.0636988 & 0.153576 & 0.919171 & 0.140223 & 0.0825558 & $\\dots$ \\\\\n",
       "\t10 & 0.958762 & 0.368439 & 0.0191283 & 0.717186 & 0.0771803 & 0.386313 & 0.05567 & 0.574292 & $\\dots$ \\\\\n",
       "\t11 & 0.0630877 & 0.834178 & 0.904894 & 0.483445 & 0.393452 & 0.937474 & 0.802854 & 0.844619 & $\\dots$ \\\\\n",
       "\t12 & 0.65562 & 0.733142 & 0.671057 & 0.355558 & 0.246691 & 0.775784 & 0.619014 & 0.18217 & $\\dots$ \\\\\n",
       "\t13 & 0.946392 & 0.695418 & 0.516211 & 0.486641 & 0.310322 & 0.307265 & 0.938915 & 0.250204 & $\\dots$ \\\\\n",
       "\t14 & 0.503955 & 0.589702 & 0.616751 & 0.945406 & 0.877692 & 0.206424 & 0.91199 & 0.893462 & $\\dots$ \\\\\n",
       "\t15 & 0.499284 & 0.311172 & 0.0956649 & 0.979099 & 0.811256 & 0.618866 & 0.630661 & 0.0858452 & $\\dots$ \\\\\n",
       "\t16 & 0.978203 & 0.734465 & 0.284393 & 0.44849 & 0.618191 & 0.0564206 & 0.661726 & 0.385878 & $\\dots$ \\\\\n",
       "\t17 & 0.229373 & 0.0927034 & 0.888742 & 0.31831 & 0.317461 & 0.79476 & 0.841271 & 0.732834 & $\\dots$ \\\\\n",
       "\t18 & 0.513956 & 0.307635 & 0.0249502 & 0.916705 & 0.8457 & 0.167388 & 0.916269 & 0.299036 & $\\dots$ \\\\\n",
       "\t19 & 0.861957 & 0.967549 & 0.934819 & 0.108393 & 0.464308 & 0.419042 & 0.219305 & 0.174648 & $\\dots$ \\\\\n",
       "\t20 & 0.00664397 & 0.901527 & 0.827246 & 0.627196 & 0.0764198 & 0.820422 & 0.565004 & 0.49255 & $\\dots$ \\\\\n",
       "\t21 & 0.390871 & 0.801431 & 0.918931 & 0.0979271 & 0.592743 & 0.303345 & 0.313241 & 0.851179 & $\\dots$ \\\\\n",
       "\t22 & 0.156969 & 0.495174 & 0.157765 & 0.0894507 & 0.109911 & 0.755358 & 0.0743305 & 0.60423 & $\\dots$ \\\\\n",
       "\t23 & 0.839897 & 0.383783 & 0.756021 & 0.396748 & 0.655357 & 0.582485 & 0.87436 & 0.981817 & $\\dots$ \\\\\n",
       "\t24 & 0.74222 & 0.738414 & 0.618398 & 0.340952 & 0.876249 & 0.240001 & 0.481201 & 0.786258 & $\\dots$ \\\\\n",
       "\t25 & 0.419736 & 0.232224 & 0.0399255 & 0.113019 & 0.313992 & 0.0122699 & 0.660767 & 0.137172 & $\\dots$ \\\\\n",
       "\t26 & 0.755163 & 0.151577 & 0.775046 & 0.930667 & 0.684634 & 0.735555 & 0.296639 & 0.394769 & $\\dots$ \\\\\n",
       "\t27 & 0.0882264 & 0.45015 & 0.0226739 & 0.097282 & 0.584313 & 0.0960262 & 0.741087 & 0.970699 & $\\dots$ \\\\\n",
       "\t28 & 0.145551 & 0.978237 & 0.615475 & 0.746586 & 0.744925 & 0.60964 & 0.351659 & 0.997235 & $\\dots$ \\\\\n",
       "\t29 & 0.792067 & 0.424946 & 0.372801 & 0.32207 & 0.596983 & 0.504858 & 0.798345 & 0.0965333 & $\\dots$ \\\\\n",
       "\t30 & 0.147033 & 0.386304 & 0.010448 & 0.98077 & 0.410856 & 0.337126 & 0.440139 & 0.0756289 & $\\dots$ \\\\\n",
       "\t$\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ &  \\\\\n",
       "\\end{tabular}\n"
      ],
      "text/plain": [
       "\u001b[1m100×100 DataFrame\u001b[0m\n",
       "\u001b[1m Row \u001b[0m│\u001b[1m x1         \u001b[0m\u001b[1m x2         \u001b[0m\u001b[1m x3         \u001b[0m\u001b[1m x4        \u001b[0m\u001b[1m x5        \u001b[0m\u001b[1m x6        \u001b[0m\u001b[1m x7\u001b[0m ⋯\n",
       "\u001b[1m     \u001b[0m│\u001b[90m Float64    \u001b[0m\u001b[90m Float64    \u001b[0m\u001b[90m Float64    \u001b[0m\u001b[90m Float64   \u001b[0m\u001b[90m Float64   \u001b[0m\u001b[90m Float64   \u001b[0m\u001b[90m Fl\u001b[0m ⋯\n",
       "─────┼──────────────────────────────────────────────────────────────────────────\n",
       "   1 │ 0.0407606   0.117232    0.348204    0.269438   0.452216   0.31456    0. ⋯\n",
       "   2 │ 0.376506    0.482919    0.669578    0.43432    0.975168   0.03292    0.\n",
       "   3 │ 0.753126    0.00911066  0.991773    0.296264   0.270301   0.0932391  0.\n",
       "   4 │ 0.814347    0.312632    0.805042    0.545419   0.169538   0.688139   0.\n",
       "   5 │ 0.584648    0.449159    0.781232    0.704917   0.401786   0.262193   0. ⋯\n",
       "   6 │ 0.557345    0.106035    0.788548    0.216535   0.678853   0.572301   0.\n",
       "   7 │ 0.29653     0.932721    0.316042    0.667673   0.66609    0.0961946  0.\n",
       "   8 │ 0.0647716   0.423136    0.449464    0.0786289  0.114109   0.186914   0.\n",
       "   9 │ 0.650907    0.443851    0.433511    0.0636988  0.153576   0.919171   0. ⋯\n",
       "  10 │ 0.958762    0.368439    0.0191283   0.717186   0.0771803  0.386313   0.\n",
       "  11 │ 0.0630877   0.834178    0.904894    0.483445   0.393452   0.937474   0.\n",
       "  ⋮  │     ⋮           ⋮           ⋮           ⋮          ⋮          ⋮         ⋱\n",
       "  91 │ 0.222388    0.453579    0.959797    0.156895   0.186409   0.0349322  0.\n",
       "  92 │ 0.762059    0.393998    0.333282    0.956779   0.339576   0.757982   0. ⋯\n",
       "  93 │ 0.00991697  0.766719    0.60944     0.835101   0.761562   0.0601347  0.\n",
       "  94 │ 0.0901556   0.895646    0.298034    0.889622   0.743927   0.1101     0.\n",
       "  95 │ 0.452569    0.571748    0.228939    0.324677   0.206253   0.549681   0.\n",
       "  96 │ 0.397988    0.3217      0.114941    0.525671   0.785238   0.566833   0. ⋯\n",
       "  97 │ 0.724444    0.905907    0.00694456  0.515093   0.745151   0.339138   0.\n",
       "  98 │ 0.11461     0.580277    0.970491    0.150659   0.172359   0.680089   0.\n",
       "  99 │ 0.0644823   0.0845724   0.162011    0.599603   0.740416   0.58457    0.\n",
       " 100 │ 0.612621    0.639837    0.0197682   0.547422   0.445893   0.844069   0. ⋯\n",
       "\u001b[31m                                                  94 columns and 79 rows omitted\u001b[0m"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = DataFrame(rand(100, 100), :auto)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "we can see that 92 of its columns were not printed. Also we get its first 30 rows. You can easily change this behavior by changing the value of `ENV[\"LINES\"]` and `ENV[\"COLUMNS\"]`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "10"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ENV[\"LINES\"] = 10"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "200"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ENV[\"COLUMNS\"] = 200"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table class=\"data-frame\"><thead><tr><th></th><th>x1</th><th>x2</th><th>x3</th><th>x4</th><th>x5</th><th>x6</th><th>x7</th><th>x8</th><th>x9</th><th>x10</th><th>x11</th><th>x12</th><th>x13</th><th>x14</th><th>x15</th><th>x16</th><th>x17</th><th>x18</th><th>x19</th></tr><tr><th></th><th>Float64</th><th>Float64</th><th>Float64</th><th>Float64</th><th>Float64</th><th>Float64</th><th>Float64</th><th>Float64</th><th>Float64</th><th>Float64</th><th>Float64</th><th>Float64</th><th>Float64</th><th>Float64</th><th>Float64</th><th>Float64</th><th>Float64</th><th>Float64</th><th>Float64</th></tr></thead><tbody><p>100 rows × 100 columns (omitted printing of 81 columns)</p><tr><th>1</th><td>0.0407606</td><td>0.117232</td><td>0.348204</td><td>0.269438</td><td>0.452216</td><td>0.31456</td><td>0.677597</td><td>0.719277</td><td>0.615861</td><td>0.36204</td><td>0.671318</td><td>0.45735</td><td>0.238713</td><td>0.647599</td><td>0.393895</td><td>0.611443</td><td>0.0909405</td><td>0.236412</td><td>0.990843</td></tr><tr><th>2</th><td>0.376506</td><td>0.482919</td><td>0.669578</td><td>0.43432</td><td>0.975168</td><td>0.03292</td><td>0.181948</td><td>0.232741</td><td>0.0667648</td><td>0.160548</td><td>0.65104</td><td>0.336965</td><td>0.94655</td><td>0.751701</td><td>0.137363</td><td>0.0701963</td><td>0.846639</td><td>0.422752</td><td>0.429095</td></tr><tr><th>3</th><td>0.753126</td><td>0.00911066</td><td>0.991773</td><td>0.296264</td><td>0.270301</td><td>0.0932391</td><td>0.494824</td><td>0.97819</td><td>0.996029</td><td>0.222652</td><td>0.949151</td><td>0.851107</td><td>0.497406</td><td>0.131852</td><td>0.288838</td><td>0.906171</td><td>0.111243</td><td>0.366607</td><td>0.693664</td></tr><tr><th>4</th><td>0.814347</td><td>0.312632</td><td>0.805042</td><td>0.545419</td><td>0.169538</td><td>0.688139</td><td>0.600611</td><td>0.591047</td><td>0.596966</td><td>0.370545</td><td>0.922549</td><td>0.478018</td><td>0.0408179</td><td>0.400419</td><td>0.761952</td><td>0.752568</td><td>0.0598793</td><td>0.762053</td><td>0.765239</td></tr><tr><th>5</th><td>0.584648</td><td>0.449159</td><td>0.781232</td><td>0.704917</td><td>0.401786</td><td>0.262193</td><td>0.763988</td><td>0.114793</td><td>0.852059</td><td>0.338727</td><td>0.117684</td><td>0.746356</td><td>0.115795</td><td>0.184791</td><td>0.140508</td><td>0.187075</td><td>0.347514</td><td>0.211822</td><td>0.261907</td></tr><tr><th>6</th><td>0.557345</td><td>0.106035</td><td>0.788548</td><td>0.216535</td><td>0.678853</td><td>0.572301</td><td>0.231112</td><td>0.367835</td><td>0.0288492</td><td>0.0479094</td><td>0.612561</td><td>0.0194852</td><td>0.0324983</td><td>0.150302</td><td>0.524042</td><td>0.548574</td><td>0.652731</td><td>0.780659</td><td>0.644513</td></tr><tr><th>7</th><td>0.29653</td><td>0.932721</td><td>0.316042</td><td>0.667673</td><td>0.66609</td><td>0.0961946</td><td>0.837986</td><td>0.901083</td><td>0.0271284</td><td>0.23356</td><td>0.822109</td><td>0.807471</td><td>0.302836</td><td>0.00490122</td><td>0.416054</td><td>0.844796</td><td>0.133597</td><td>0.555466</td><td>0.742581</td></tr><tr><th>8</th><td>0.0647716</td><td>0.423136</td><td>0.449464</td><td>0.0786289</td><td>0.114109</td><td>0.186914</td><td>0.321308</td><td>0.212699</td><td>0.453385</td><td>0.697554</td><td>0.55713</td><td>0.675983</td><td>0.53533</td><td>0.676487</td><td>0.317385</td><td>0.359657</td><td>0.79792</td><td>0.243943</td><td>0.46387</td></tr><tr><th>9</th><td>0.650907</td><td>0.443851</td><td>0.433511</td><td>0.0636988</td><td>0.153576</td><td>0.919171</td><td>0.140223</td><td>0.0825558</td><td>0.0033033</td><td>0.847624</td><td>0.191551</td><td>0.574725</td><td>0.341964</td><td>0.659708</td><td>0.701146</td><td>0.0615678</td><td>0.566943</td><td>0.35424</td><td>0.818846</td></tr><tr><th>10</th><td>0.958762</td><td>0.368439</td><td>0.0191283</td><td>0.717186</td><td>0.0771803</td><td>0.386313</td><td>0.05567</td><td>0.574292</td><td>0.0668751</td><td>0.563988</td><td>0.446098</td><td>0.838466</td><td>0.211583</td><td>0.671035</td><td>0.770441</td><td>0.0935197</td><td>0.536912</td><td>0.718397</td><td>0.966319</td></tr><tr><th>&vellip;</th><td>&vellip;</td><td>&vellip;</td><td>&vellip;</td><td>&vellip;</td><td>&vellip;</td><td>&vellip;</td><td>&vellip;</td><td>&vellip;</td><td>&vellip;</td><td>&vellip;</td><td>&vellip;</td><td>&vellip;</td><td>&vellip;</td><td>&vellip;</td><td>&vellip;</td><td>&vellip;</td><td>&vellip;</td><td>&vellip;</td><td>&vellip;</td></tr></tbody></table>"
      ],
      "text/latex": [
       "\\begin{tabular}{r|cccccccccccccccccccc}\n",
       "\t& x1 & x2 & x3 & x4 & x5 & x6 & x7 & x8 & x9 & x10 & x11 & x12 & x13 & x14 & x15 & x16 & x17 & x18 & x19 & \\\\\n",
       "\t\\hline\n",
       "\t& Float64 & Float64 & Float64 & Float64 & Float64 & Float64 & Float64 & Float64 & Float64 & Float64 & Float64 & Float64 & Float64 & Float64 & Float64 & Float64 & Float64 & Float64 & Float64 & \\\\\n",
       "\t\\hline\n",
       "\t1 & 0.0407606 & 0.117232 & 0.348204 & 0.269438 & 0.452216 & 0.31456 & 0.677597 & 0.719277 & 0.615861 & 0.36204 & 0.671318 & 0.45735 & 0.238713 & 0.647599 & 0.393895 & 0.611443 & 0.0909405 & 0.236412 & 0.990843 & $\\dots$ \\\\\n",
       "\t2 & 0.376506 & 0.482919 & 0.669578 & 0.43432 & 0.975168 & 0.03292 & 0.181948 & 0.232741 & 0.0667648 & 0.160548 & 0.65104 & 0.336965 & 0.94655 & 0.751701 & 0.137363 & 0.0701963 & 0.846639 & 0.422752 & 0.429095 & $\\dots$ \\\\\n",
       "\t3 & 0.753126 & 0.00911066 & 0.991773 & 0.296264 & 0.270301 & 0.0932391 & 0.494824 & 0.97819 & 0.996029 & 0.222652 & 0.949151 & 0.851107 & 0.497406 & 0.131852 & 0.288838 & 0.906171 & 0.111243 & 0.366607 & 0.693664 & $\\dots$ \\\\\n",
       "\t4 & 0.814347 & 0.312632 & 0.805042 & 0.545419 & 0.169538 & 0.688139 & 0.600611 & 0.591047 & 0.596966 & 0.370545 & 0.922549 & 0.478018 & 0.0408179 & 0.400419 & 0.761952 & 0.752568 & 0.0598793 & 0.762053 & 0.765239 & $\\dots$ \\\\\n",
       "\t5 & 0.584648 & 0.449159 & 0.781232 & 0.704917 & 0.401786 & 0.262193 & 0.763988 & 0.114793 & 0.852059 & 0.338727 & 0.117684 & 0.746356 & 0.115795 & 0.184791 & 0.140508 & 0.187075 & 0.347514 & 0.211822 & 0.261907 & $\\dots$ \\\\\n",
       "\t6 & 0.557345 & 0.106035 & 0.788548 & 0.216535 & 0.678853 & 0.572301 & 0.231112 & 0.367835 & 0.0288492 & 0.0479094 & 0.612561 & 0.0194852 & 0.0324983 & 0.150302 & 0.524042 & 0.548574 & 0.652731 & 0.780659 & 0.644513 & $\\dots$ \\\\\n",
       "\t7 & 0.29653 & 0.932721 & 0.316042 & 0.667673 & 0.66609 & 0.0961946 & 0.837986 & 0.901083 & 0.0271284 & 0.23356 & 0.822109 & 0.807471 & 0.302836 & 0.00490122 & 0.416054 & 0.844796 & 0.133597 & 0.555466 & 0.742581 & $\\dots$ \\\\\n",
       "\t8 & 0.0647716 & 0.423136 & 0.449464 & 0.0786289 & 0.114109 & 0.186914 & 0.321308 & 0.212699 & 0.453385 & 0.697554 & 0.55713 & 0.675983 & 0.53533 & 0.676487 & 0.317385 & 0.359657 & 0.79792 & 0.243943 & 0.46387 & $\\dots$ \\\\\n",
       "\t9 & 0.650907 & 0.443851 & 0.433511 & 0.0636988 & 0.153576 & 0.919171 & 0.140223 & 0.0825558 & 0.0033033 & 0.847624 & 0.191551 & 0.574725 & 0.341964 & 0.659708 & 0.701146 & 0.0615678 & 0.566943 & 0.35424 & 0.818846 & $\\dots$ \\\\\n",
       "\t10 & 0.958762 & 0.368439 & 0.0191283 & 0.717186 & 0.0771803 & 0.386313 & 0.05567 & 0.574292 & 0.0668751 & 0.563988 & 0.446098 & 0.838466 & 0.211583 & 0.671035 & 0.770441 & 0.0935197 & 0.536912 & 0.718397 & 0.966319 & $\\dots$ \\\\\n",
       "\t$\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ & $\\dots$ &  \\\\\n",
       "\\end{tabular}\n"
      ],
      "text/plain": [
       "\u001b[1m100×100 DataFrame\u001b[0m\n",
       "\u001b[1m Row \u001b[0m│\u001b[1m x1        \u001b[0m\u001b[1m x2         \u001b[0m\u001b[1m x3         \u001b[0m\u001b[1m x4       \u001b[0m\u001b[1m x5       \u001b[0m\u001b[1m x6        \u001b[0m\u001b[1m x7        \u001b[0m\u001b[1m x8       \u001b[0m\u001b[1m x9        \u001b[0m\u001b[1m x10      \u001b[0m\u001b[1m x11      \u001b[0m\u001b[1m x12       \u001b[0m\u001b[1m x13       \u001b[0m\u001b[1m x14      \u001b[0m\u001b[1m x15      \u001b[0m\u001b[1m x16       \u001b[0m\u001b[1m x17       \u001b[0m\u001b[1m x18      \u001b[0m ⋯\n",
       "\u001b[1m     \u001b[0m│\u001b[90m Float64   \u001b[0m\u001b[90m Float64    \u001b[0m\u001b[90m Float64    \u001b[0m\u001b[90m Float64  \u001b[0m\u001b[90m Float64  \u001b[0m\u001b[90m Float64   \u001b[0m\u001b[90m Float64   \u001b[0m\u001b[90m Float64  \u001b[0m\u001b[90m Float64   \u001b[0m\u001b[90m Float64  \u001b[0m\u001b[90m Float64  \u001b[0m\u001b[90m Float64   \u001b[0m\u001b[90m Float64   \u001b[0m\u001b[90m Float64  \u001b[0m\u001b[90m Float64  \u001b[0m\u001b[90m Float64   \u001b[0m\u001b[90m Float64   \u001b[0m\u001b[90m Float64  \u001b[0m ⋯\n",
       "─────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────\n",
       "   1 │ 0.0407606  0.117232    0.348204    0.269438  0.452216  0.31456    0.677597   0.719277  0.615861   0.36204   0.671318  0.45735    0.238713   0.647599  0.393895  0.611443   0.0909405  0.236412  ⋯\n",
       "  ⋮  │     ⋮          ⋮           ⋮          ⋮         ⋮          ⋮          ⋮         ⋮          ⋮         ⋮         ⋮          ⋮          ⋮         ⋮         ⋮          ⋮          ⋮          ⋮     ⋱\n",
       "\u001b[31m                                                                                                                                                                          82 columns and 99 rows omitted\u001b[0m"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Most elementary get and set operations\n",
    "\n",
    "Given the `DataFrame` `x` we have created earlier, here are various ways to grab one of its columns as a `Vector`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table class=\"data-frame\"><thead><tr><th></th><th>A</th><th>B</th><th>C</th></tr><tr><th></th><th>Int64</th><th>Float64?</th><th>String</th></tr></thead><tbody><p>2 rows × 3 columns</p><tr><th>1</th><td>1</td><td>1.0</td><td>a</td></tr><tr><th>2</th><td>2</td><td><em>missing</em></td><td>b</td></tr></tbody></table>"
      ],
      "text/latex": [
       "\\begin{tabular}{r|ccc}\n",
       "\t& A & B & C\\\\\n",
       "\t\\hline\n",
       "\t& Int64 & Float64? & String\\\\\n",
       "\t\\hline\n",
       "\t1 & 1 & 1.0 & a \\\\\n",
       "\t2 & 2 & \\emph{missing} & b \\\\\n",
       "\\end{tabular}\n"
      ],
      "text/plain": [
       "\u001b[1m2×3 DataFrame\u001b[0m\n",
       "\u001b[1m Row \u001b[0m│\u001b[1m A     \u001b[0m\u001b[1m B         \u001b[0m\u001b[1m C      \u001b[0m\n",
       "\u001b[1m     \u001b[0m│\u001b[90m Int64 \u001b[0m\u001b[90m Float64?  \u001b[0m\u001b[90m String \u001b[0m\n",
       "─────┼──────────────────────────\n",
       "   1 │     1        1.0  a\n",
       "   2 │     2 \u001b[90m missing   \u001b[0m b"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "([1, 2], [1, 2], [1, 2])"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x.A, x[!, 1], x[!, :A] # all get the vector stored in our DataFrame without copying it"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "([1, 2], [1, 2])"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x.\"A\", x[!, \"A\"] # the same using string indexing"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2-element Array{Int64,1}:\n",
       " 1\n",
       " 2"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x[:, 1] # note that this creates a copy"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "false"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x[:, 1] === x[:, 1]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "To grab one row as a `DataFrame`, we can index as follows."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table class=\"data-frame\"><thead><tr><th></th><th>A</th><th>B</th><th>C</th></tr><tr><th></th><th>Int64</th><th>Float64?</th><th>String</th></tr></thead><tbody><p>1 rows × 3 columns</p><tr><th>1</th><td>1</td><td>1.0</td><td>a</td></tr></tbody></table>"
      ],
      "text/latex": [
       "\\begin{tabular}{r|ccc}\n",
       "\t& A & B & C\\\\\n",
       "\t\\hline\n",
       "\t& Int64 & Float64? & String\\\\\n",
       "\t\\hline\n",
       "\t1 & 1 & 1.0 & a \\\\\n",
       "\\end{tabular}\n"
      ],
      "text/plain": [
       "\u001b[1m1×3 DataFrame\u001b[0m\n",
       "\u001b[1m Row \u001b[0m│\u001b[1m A     \u001b[0m\u001b[1m B        \u001b[0m\u001b[1m C      \u001b[0m\n",
       "\u001b[1m     \u001b[0m│\u001b[90m Int64 \u001b[0m\u001b[90m Float64? \u001b[0m\u001b[90m String \u001b[0m\n",
       "─────┼─────────────────────────\n",
       "   1 │     1       1.0  a"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x[1:1, :]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<p>DataFrameRow (3 columns)</p><table class=\"data-frame\"><thead><tr><th></th><th>A</th><th>B</th><th>C</th></tr><tr><th></th><th>Int64</th><th>Float64?</th><th>String</th></tr></thead><tbody><tr><th>1</th><td>1</td><td>1.0</td><td>a</td></tr></tbody></table>"
      ],
      "text/latex": [
       "\\begin{tabular}{r|ccc}\n",
       "\t& A & B & C\\\\\n",
       "\t\\hline\n",
       "\t& Int64 & Float64? & String\\\\\n",
       "\t\\hline\n",
       "\t1 & 1 & 1.0 & a \\\\\n",
       "\\end{tabular}\n"
      ],
      "text/plain": [
       "\u001b[1mDataFrameRow\u001b[0m\n",
       "\u001b[1m Row \u001b[0m│\u001b[1m A     \u001b[0m\u001b[1m B        \u001b[0m\u001b[1m C      \u001b[0m\n",
       "\u001b[1m     \u001b[0m│\u001b[90m Int64 \u001b[0m\u001b[90m Float64? \u001b[0m\u001b[90m String \u001b[0m\n",
       "─────┼─────────────────────────\n",
       "   1 │     1       1.0  a"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x[1, :] # this produces a DataFrameRow which is treated as 1-dimensional object similar to a NamedTuple"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We can grab a single cell or element with the same syntax to grab an element of an array."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x[1, 1]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "or a new `DataFrame` that is a subset of rows and columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table class=\"data-frame\"><thead><tr><th></th><th>A</th><th>B</th></tr><tr><th></th><th>Int64</th><th>Float64?</th></tr></thead><tbody><p>2 rows × 2 columns</p><tr><th>1</th><td>1</td><td>1.0</td></tr><tr><th>2</th><td>2</td><td><em>missing</em></td></tr></tbody></table>"
      ],
      "text/latex": [
       "\\begin{tabular}{r|cc}\n",
       "\t& A & B\\\\\n",
       "\t\\hline\n",
       "\t& Int64 & Float64?\\\\\n",
       "\t\\hline\n",
       "\t1 & 1 & 1.0 \\\\\n",
       "\t2 & 2 & \\emph{missing} \\\\\n",
       "\\end{tabular}\n"
      ],
      "text/plain": [
       "\u001b[1m2×2 DataFrame\u001b[0m\n",
       "\u001b[1m Row \u001b[0m│\u001b[1m A     \u001b[0m\u001b[1m B         \u001b[0m\n",
       "\u001b[1m     \u001b[0m│\u001b[90m Int64 \u001b[0m\u001b[90m Float64?  \u001b[0m\n",
       "─────┼──────────────────\n",
       "   1 │     1        1.0\n",
       "   2 │     2 \u001b[90m missing   \u001b[0m"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x[1:2, 1:2]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "You can also use `Regex` to select columns and `Not` from InvertedIndices.jl both to select rows and columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table class=\"data-frame\"><thead><tr><th></th><th>A</th></tr><tr><th></th><th>Int64</th></tr></thead><tbody><p>1 rows × 1 columns</p><tr><th>1</th><td>2</td></tr></tbody></table>"
      ],
      "text/latex": [
       "\\begin{tabular}{r|c}\n",
       "\t& A\\\\\n",
       "\t\\hline\n",
       "\t& Int64\\\\\n",
       "\t\\hline\n",
       "\t1 & 2 \\\\\n",
       "\\end{tabular}\n"
      ],
      "text/plain": [
       "\u001b[1m1×1 DataFrame\u001b[0m\n",
       "\u001b[1m Row \u001b[0m│\u001b[1m A     \u001b[0m\n",
       "\u001b[1m     \u001b[0m│\u001b[90m Int64 \u001b[0m\n",
       "─────┼───────\n",
       "   1 │     2"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x[Not(1), r\"A\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table class=\"data-frame\"><thead><tr><th></th><th>B</th><th>C</th></tr><tr><th></th><th>Float64?</th><th>String</th></tr></thead><tbody><p>2 rows × 2 columns</p><tr><th>1</th><td>1.0</td><td>a</td></tr><tr><th>2</th><td><em>missing</em></td><td>b</td></tr></tbody></table>"
      ],
      "text/latex": [
       "\\begin{tabular}{r|cc}\n",
       "\t& B & C\\\\\n",
       "\t\\hline\n",
       "\t& Float64? & String\\\\\n",
       "\t\\hline\n",
       "\t1 & 1.0 & a \\\\\n",
       "\t2 & \\emph{missing} & b \\\\\n",
       "\\end{tabular}\n"
      ],
      "text/plain": [
       "\u001b[1m2×2 DataFrame\u001b[0m\n",
       "\u001b[1m Row \u001b[0m│\u001b[1m B         \u001b[0m\u001b[1m C      \u001b[0m\n",
       "\u001b[1m     \u001b[0m│\u001b[90m Float64?  \u001b[0m\u001b[90m String \u001b[0m\n",
       "─────┼───────────────────\n",
       "   1 │       1.0  a\n",
       "   2 │\u001b[90m missing   \u001b[0m b"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x[!, Not(1)] # ! indicates that underlying columns are not copied"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table class=\"data-frame\"><thead><tr><th></th><th>B</th><th>C</th></tr><tr><th></th><th>Float64?</th><th>String</th></tr></thead><tbody><p>2 rows × 2 columns</p><tr><th>1</th><td>1.0</td><td>a</td></tr><tr><th>2</th><td><em>missing</em></td><td>b</td></tr></tbody></table>"
      ],
      "text/latex": [
       "\\begin{tabular}{r|cc}\n",
       "\t& B & C\\\\\n",
       "\t\\hline\n",
       "\t& Float64? & String\\\\\n",
       "\t\\hline\n",
       "\t1 & 1.0 & a \\\\\n",
       "\t2 & \\emph{missing} & b \\\\\n",
       "\\end{tabular}\n"
      ],
      "text/plain": [
       "\u001b[1m2×2 DataFrame\u001b[0m\n",
       "\u001b[1m Row \u001b[0m│\u001b[1m B         \u001b[0m\u001b[1m C      \u001b[0m\n",
       "\u001b[1m     \u001b[0m│\u001b[90m Float64?  \u001b[0m\u001b[90m String \u001b[0m\n",
       "─────┼───────────────────\n",
       "   1 │       1.0  a\n",
       "   2 │\u001b[90m missing   \u001b[0m b"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x[:, Not(1)] # : means that the columns will get copied"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Assignment of a scalar to a data frame can be done in ranges using broadcasting:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table class=\"data-frame\"><thead><tr><th></th><th>A</th><th>B</th><th>C</th></tr><tr><th></th><th>Int64</th><th>Float64?</th><th>String</th></tr></thead><tbody><p>2 rows × 3 columns</p><tr><th>1</th><td>1</td><td>1.0</td><td>a</td></tr><tr><th>2</th><td>1</td><td>1.0</td><td>b</td></tr></tbody></table>"
      ],
      "text/latex": [
       "\\begin{tabular}{r|ccc}\n",
       "\t& A & B & C\\\\\n",
       "\t\\hline\n",
       "\t& Int64 & Float64? & String\\\\\n",
       "\t\\hline\n",
       "\t1 & 1 & 1.0 & a \\\\\n",
       "\t2 & 1 & 1.0 & b \\\\\n",
       "\\end{tabular}\n"
      ],
      "text/plain": [
       "\u001b[1m2×3 DataFrame\u001b[0m\n",
       "\u001b[1m Row \u001b[0m│\u001b[1m A     \u001b[0m\u001b[1m B        \u001b[0m\u001b[1m C      \u001b[0m\n",
       "\u001b[1m     \u001b[0m│\u001b[90m Int64 \u001b[0m\u001b[90m Float64? \u001b[0m\u001b[90m String \u001b[0m\n",
       "─────┼─────────────────────────\n",
       "   1 │     1       1.0  a\n",
       "   2 │     1       1.0  b"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x[1:2, 1:2] .= 1\n",
    "x"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Assignment of a vector of length equal to the number of assigned rows using broadcasting"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table class=\"data-frame\"><thead><tr><th></th><th>A</th><th>B</th><th>C</th></tr><tr><th></th><th>Int64</th><th>Float64?</th><th>String</th></tr></thead><tbody><p>2 rows × 3 columns</p><tr><th>1</th><td>1</td><td>1.0</td><td>a</td></tr><tr><th>2</th><td>2</td><td>2.0</td><td>b</td></tr></tbody></table>"
      ],
      "text/latex": [
       "\\begin{tabular}{r|ccc}\n",
       "\t& A & B & C\\\\\n",
       "\t\\hline\n",
       "\t& Int64 & Float64? & String\\\\\n",
       "\t\\hline\n",
       "\t1 & 1 & 1.0 & a \\\\\n",
       "\t2 & 2 & 2.0 & b \\\\\n",
       "\\end{tabular}\n"
      ],
      "text/plain": [
       "\u001b[1m2×3 DataFrame\u001b[0m\n",
       "\u001b[1m Row \u001b[0m│\u001b[1m A     \u001b[0m\u001b[1m B        \u001b[0m\u001b[1m C      \u001b[0m\n",
       "\u001b[1m     \u001b[0m│\u001b[90m Int64 \u001b[0m\u001b[90m Float64? \u001b[0m\u001b[90m String \u001b[0m\n",
       "─────┼─────────────────────────\n",
       "   1 │     1       1.0  a\n",
       "   2 │     2       2.0  b"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x[1:2, 1:2] .= [1,2]\n",
    "x"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Assignment or of another data frame of matching size and column names, again using broadcasting:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table class=\"data-frame\"><thead><tr><th></th><th>A</th><th>B</th><th>C</th></tr><tr><th></th><th>Int64</th><th>Float64?</th><th>String</th></tr></thead><tbody><p>2 rows × 3 columns</p><tr><th>1</th><td>5</td><td>6.0</td><td>a</td></tr><tr><th>2</th><td>7</td><td>8.0</td><td>b</td></tr></tbody></table>"
      ],
      "text/latex": [
       "\\begin{tabular}{r|ccc}\n",
       "\t& A & B & C\\\\\n",
       "\t\\hline\n",
       "\t& Int64 & Float64? & String\\\\\n",
       "\t\\hline\n",
       "\t1 & 5 & 6.0 & a \\\\\n",
       "\t2 & 7 & 8.0 & b \\\\\n",
       "\\end{tabular}\n"
      ],
      "text/plain": [
       "\u001b[1m2×3 DataFrame\u001b[0m\n",
       "\u001b[1m Row \u001b[0m│\u001b[1m A     \u001b[0m\u001b[1m B        \u001b[0m\u001b[1m C      \u001b[0m\n",
       "\u001b[1m     \u001b[0m│\u001b[90m Int64 \u001b[0m\u001b[90m Float64? \u001b[0m\u001b[90m String \u001b[0m\n",
       "─────┼─────────────────────────\n",
       "   1 │     5       6.0  a\n",
       "   2 │     7       8.0  b"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x[1:2, 1:2] .= DataFrame([5 6; 7 8], [:A, :B])\n",
    "x"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Caution**\n",
    "\n",
    "With `df[!, :col]` and `df.col` syntax you get a direct (non copying) access to a column of a data frame.\n",
    "This is potentially unsafe as you can easily corrupt data in the `df` data frame if you resize, sort, etc. the column obtained in this way.\n",
    "Therefore such access should be used with caution.\n",
    "\n",
    "Similarly `df[!, cols]` when `cols` is a collection of columns produces a new data frame that holds the same (not copied) columns as the source `df` data frame. Similarly, modifying the data frame obtained via `df[!, cols]` might cause problems with the consistency of `df`.\n",
    "\n",
    "The `df[:, :col]` and `df[:, cols]` syntaxes always copy columns so they are safe to use (and should generally be preferred except for performance or memory critical use cases)."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Here are examples of how `Cols` and `Between` can be used to select columns of a data frame."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table class=\"data-frame\"><thead><tr><th></th><th>x1</th><th>x2</th><th>x3</th><th>x4</th><th>x5</th></tr><tr><th></th><th>Float64</th><th>Float64</th><th>Float64</th><th>Float64</th><th>Float64</th></tr></thead><tbody><p>4 rows × 5 columns</p><tr><th>1</th><td>0.779175</td><td>0.571052</td><td>0.00519813</td><td>0.580951</td><td>0.727203</td></tr><tr><th>2</th><td>0.284709</td><td>0.264599</td><td>0.618271</td><td>0.625157</td><td>0.265699</td></tr><tr><th>3</th><td>0.956069</td><td>0.0278224</td><td>0.875838</td><td>0.0169878</td><td>0.396787</td></tr><tr><th>4</th><td>0.853433</td><td>0.577229</td><td>0.378074</td><td>0.225203</td><td>0.747455</td></tr></tbody></table>"
      ],
      "text/latex": [
       "\\begin{tabular}{r|ccccc}\n",
       "\t& x1 & x2 & x3 & x4 & x5\\\\\n",
       "\t\\hline\n",
       "\t& Float64 & Float64 & Float64 & Float64 & Float64\\\\\n",
       "\t\\hline\n",
       "\t1 & 0.779175 & 0.571052 & 0.00519813 & 0.580951 & 0.727203 \\\\\n",
       "\t2 & 0.284709 & 0.264599 & 0.618271 & 0.625157 & 0.265699 \\\\\n",
       "\t3 & 0.956069 & 0.0278224 & 0.875838 & 0.0169878 & 0.396787 \\\\\n",
       "\t4 & 0.853433 & 0.577229 & 0.378074 & 0.225203 & 0.747455 \\\\\n",
       "\\end{tabular}\n"
      ],
      "text/plain": [
       "\u001b[1m4×5 DataFrame\u001b[0m\n",
       "\u001b[1m Row \u001b[0m│\u001b[1m x1       \u001b[0m\u001b[1m x2        \u001b[0m\u001b[1m x3         \u001b[0m\u001b[1m x4        \u001b[0m\u001b[1m x5       \u001b[0m\n",
       "\u001b[1m     \u001b[0m│\u001b[90m Float64  \u001b[0m\u001b[90m Float64   \u001b[0m\u001b[90m Float64    \u001b[0m\u001b[90m Float64   \u001b[0m\u001b[90m Float64  \u001b[0m\n",
       "─────┼──────────────────────────────────────────────────────\n",
       "   1 │ 0.779175  0.571052   0.00519813  0.580951   0.727203\n",
       "  ⋮  │    ⋮          ⋮          ⋮           ⋮         ⋮\n",
       "\u001b[31m                                              3 rows omitted\u001b[0m"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x = DataFrame(rand(4, 5), :auto)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table class=\"data-frame\"><thead><tr><th></th><th>x2</th><th>x3</th><th>x4</th></tr><tr><th></th><th>Float64</th><th>Float64</th><th>Float64</th></tr></thead><tbody><p>4 rows × 3 columns</p><tr><th>1</th><td>0.571052</td><td>0.00519813</td><td>0.580951</td></tr><tr><th>2</th><td>0.264599</td><td>0.618271</td><td>0.625157</td></tr><tr><th>3</th><td>0.0278224</td><td>0.875838</td><td>0.0169878</td></tr><tr><th>4</th><td>0.577229</td><td>0.378074</td><td>0.225203</td></tr></tbody></table>"
      ],
      "text/latex": [
       "\\begin{tabular}{r|ccc}\n",
       "\t& x2 & x3 & x4\\\\\n",
       "\t\\hline\n",
       "\t& Float64 & Float64 & Float64\\\\\n",
       "\t\\hline\n",
       "\t1 & 0.571052 & 0.00519813 & 0.580951 \\\\\n",
       "\t2 & 0.264599 & 0.618271 & 0.625157 \\\\\n",
       "\t3 & 0.0278224 & 0.875838 & 0.0169878 \\\\\n",
       "\t4 & 0.577229 & 0.378074 & 0.225203 \\\\\n",
       "\\end{tabular}\n"
      ],
      "text/plain": [
       "\u001b[1m4×3 DataFrame\u001b[0m\n",
       "\u001b[1m Row \u001b[0m│\u001b[1m x2        \u001b[0m\u001b[1m x3         \u001b[0m\u001b[1m x4        \u001b[0m\n",
       "\u001b[1m     \u001b[0m│\u001b[90m Float64   \u001b[0m\u001b[90m Float64    \u001b[0m\u001b[90m Float64   \u001b[0m\n",
       "─────┼──────────────────────────────────\n",
       "   1 │ 0.571052   0.00519813  0.580951\n",
       "  ⋮  │     ⋮          ⋮           ⋮\n",
       "\u001b[31m                          3 rows omitted\u001b[0m"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x[:, Between(:x2, :x4)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table class=\"data-frame\"><thead><tr><th></th><th>x1</th><th>x2</th><th>x3</th><th>x4</th></tr><tr><th></th><th>Float64</th><th>Float64</th><th>Float64</th><th>Float64</th></tr></thead><tbody><p>4 rows × 4 columns</p><tr><th>1</th><td>0.779175</td><td>0.571052</td><td>0.00519813</td><td>0.580951</td></tr><tr><th>2</th><td>0.284709</td><td>0.264599</td><td>0.618271</td><td>0.625157</td></tr><tr><th>3</th><td>0.956069</td><td>0.0278224</td><td>0.875838</td><td>0.0169878</td></tr><tr><th>4</th><td>0.853433</td><td>0.577229</td><td>0.378074</td><td>0.225203</td></tr></tbody></table>"
      ],
      "text/latex": [
       "\\begin{tabular}{r|cccc}\n",
       "\t& x1 & x2 & x3 & x4\\\\\n",
       "\t\\hline\n",
       "\t& Float64 & Float64 & Float64 & Float64\\\\\n",
       "\t\\hline\n",
       "\t1 & 0.779175 & 0.571052 & 0.00519813 & 0.580951 \\\\\n",
       "\t2 & 0.284709 & 0.264599 & 0.618271 & 0.625157 \\\\\n",
       "\t3 & 0.956069 & 0.0278224 & 0.875838 & 0.0169878 \\\\\n",
       "\t4 & 0.853433 & 0.577229 & 0.378074 & 0.225203 \\\\\n",
       "\\end{tabular}\n"
      ],
      "text/plain": [
       "\u001b[1m4×4 DataFrame\u001b[0m\n",
       "\u001b[1m Row \u001b[0m│\u001b[1m x1       \u001b[0m\u001b[1m x2        \u001b[0m\u001b[1m x3         \u001b[0m\u001b[1m x4        \u001b[0m\n",
       "\u001b[1m     \u001b[0m│\u001b[90m Float64  \u001b[0m\u001b[90m Float64   \u001b[0m\u001b[90m Float64    \u001b[0m\u001b[90m Float64   \u001b[0m\n",
       "─────┼────────────────────────────────────────────\n",
       "   1 │ 0.779175  0.571052   0.00519813  0.580951\n",
       "  ⋮  │    ⋮          ⋮          ⋮           ⋮\n",
       "\u001b[31m                                    3 rows omitted\u001b[0m"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x[:, Cols(\"x1\", Between(\"x2\", \"x4\"))]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Views"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "You can simply create a view of a `DataFrame` (it is more efficient than creating a materialized selection). Here are the possible return value options."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2-element view(::Array{Float64,1}, 1:2) with eltype Float64:\n",
       " 0.7791753981936183\n",
       " 0.2847094117872502"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "@view x[1:2, 1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0-dimensional view(::Array{Float64,1}, 1) with eltype Float64:\n",
       "0.7791753981936183"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "@view x[1,1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<p>DataFrameRow (2 columns)</p><table class=\"data-frame\"><thead><tr><th></th><th>x1</th><th>x2</th></tr><tr><th></th><th>Float64</th><th>Float64</th></tr></thead><tbody><tr><th>1</th><td>0.779175</td><td>0.571052</td></tr></tbody></table>"
      ],
      "text/latex": [
       "\\begin{tabular}{r|cc}\n",
       "\t& x1 & x2\\\\\n",
       "\t\\hline\n",
       "\t& Float64 & Float64\\\\\n",
       "\t\\hline\n",
       "\t1 & 0.779175 & 0.571052 \\\\\n",
       "\\end{tabular}\n"
      ],
      "text/plain": [
       "\u001b[1mDataFrameRow\u001b[0m\n",
       "\u001b[1m Row \u001b[0m│\u001b[1m x1       \u001b[0m\u001b[1m x2       \u001b[0m\n",
       "\u001b[1m     \u001b[0m│\u001b[90m Float64  \u001b[0m\u001b[90m Float64  \u001b[0m\n",
       "─────┼────────────────────\n",
       "   1 │ 0.779175  0.571052"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "@view x[1, 1:2] # a DataFrameRow, the same as for x[1, 1:2] without a view"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table class=\"data-frame\"><thead><tr><th></th><th>x1</th><th>x2</th></tr><tr><th></th><th>Float64</th><th>Float64</th></tr></thead><tbody><p>2 rows × 2 columns</p><tr><th>1</th><td>0.779175</td><td>0.571052</td></tr><tr><th>2</th><td>0.284709</td><td>0.264599</td></tr></tbody></table>"
      ],
      "text/latex": [
       "\\begin{tabular}{r|cc}\n",
       "\t& x1 & x2\\\\\n",
       "\t\\hline\n",
       "\t& Float64 & Float64\\\\\n",
       "\t\\hline\n",
       "\t1 & 0.779175 & 0.571052 \\\\\n",
       "\t2 & 0.284709 & 0.264599 \\\\\n",
       "\\end{tabular}\n"
      ],
      "text/plain": [
       "\u001b[1m2×2 SubDataFrame\u001b[0m\n",
       "\u001b[1m Row \u001b[0m│\u001b[1m x1       \u001b[0m\u001b[1m x2       \u001b[0m\n",
       "\u001b[1m     \u001b[0m│\u001b[90m Float64  \u001b[0m\u001b[90m Float64  \u001b[0m\n",
       "─────┼────────────────────\n",
       "   1 │ 0.779175  0.571052\n",
       "   2 │ 0.284709  0.264599"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "@view x[1:2, 1:2] # a SubDataFrame"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Adding new columns to a data frame"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table class=\"data-frame\"><thead><tr><th></th></tr><tr><th></th></tr></thead><tbody><p>0 rows × 0 columns</p></tbody></table>"
      ],
      "text/latex": [
       "\\begin{tabular}{r|}\n",
       "\t& \\\\\n",
       "\t\\hline\n",
       "\t& \\\\\n",
       "\t\\hline\n",
       "\\end{tabular}\n"
      ],
      "text/plain": [
       "\u001b[1m0×0 DataFrame\u001b[0m"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = DataFrame()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "using `setproperty!`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table class=\"data-frame\"><thead><tr><th></th><th>a</th></tr><tr><th></th><th>Int64</th></tr></thead><tbody><p>3 rows × 1 columns</p><tr><th>1</th><td>1</td></tr><tr><th>2</th><td>2</td></tr><tr><th>3</th><td>3</td></tr></tbody></table>"
      ],
      "text/latex": [
       "\\begin{tabular}{r|c}\n",
       "\t& a\\\\\n",
       "\t\\hline\n",
       "\t& Int64\\\\\n",
       "\t\\hline\n",
       "\t1 & 1 \\\\\n",
       "\t2 & 2 \\\\\n",
       "\t3 & 3 \\\\\n",
       "\\end{tabular}\n"
      ],
      "text/plain": [
       "\u001b[1m3×1 DataFrame\u001b[0m\n",
       "\u001b[1m Row \u001b[0m│\u001b[1m a     \u001b[0m\n",
       "\u001b[1m     \u001b[0m│\u001b[90m Int64 \u001b[0m\n",
       "─────┼───────\n",
       "   1 │     1\n",
       "   2 │     2\n",
       "   3 │     3"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x = [1, 2, 3]\n",
    "df.a = x\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "true"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.a === x # no copy is performed"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "using `setindex!`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table class=\"data-frame\"><thead><tr><th></th><th>a</th><th>b</th><th>c</th></tr><tr><th></th><th>Int64</th><th>Int64</th><th>Int64</th></tr></thead><tbody><p>3 rows × 3 columns</p><tr><th>1</th><td>1</td><td>1</td><td>1</td></tr><tr><th>2</th><td>2</td><td>2</td><td>2</td></tr><tr><th>3</th><td>3</td><td>3</td><td>3</td></tr></tbody></table>"
      ],
      "text/latex": [
       "\\begin{tabular}{r|ccc}\n",
       "\t& a & b & c\\\\\n",
       "\t\\hline\n",
       "\t& Int64 & Int64 & Int64\\\\\n",
       "\t\\hline\n",
       "\t1 & 1 & 1 & 1 \\\\\n",
       "\t2 & 2 & 2 & 2 \\\\\n",
       "\t3 & 3 & 3 & 3 \\\\\n",
       "\\end{tabular}\n"
      ],
      "text/plain": [
       "\u001b[1m3×3 DataFrame\u001b[0m\n",
       "\u001b[1m Row \u001b[0m│\u001b[1m a     \u001b[0m\u001b[1m b     \u001b[0m\u001b[1m c     \u001b[0m\n",
       "\u001b[1m     \u001b[0m│\u001b[90m Int64 \u001b[0m\u001b[90m Int64 \u001b[0m\u001b[90m Int64 \u001b[0m\n",
       "─────┼─────────────────────\n",
       "   1 │     1      1      1\n",
       "   2 │     2      2      2\n",
       "   3 │     3      3      3"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[!, :b] = x\n",
    "df[:, :c] = x\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "true"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.b === x # no copy"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "false"
      ]
     },
     "execution_count": 47,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.c === x # copy"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table class=\"data-frame\"><thead><tr><th></th><th>a</th><th>b</th><th>c</th><th>d</th><th>e</th></tr><tr><th></th><th>Int64</th><th>Int64</th><th>Int64</th><th>Int64</th><th>Int64</th></tr></thead><tbody><p>3 rows × 5 columns</p><tr><th>1</th><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td></tr><tr><th>2</th><td>2</td><td>2</td><td>2</td><td>2</td><td>2</td></tr><tr><th>3</th><td>3</td><td>3</td><td>3</td><td>3</td><td>3</td></tr></tbody></table>"
      ],
      "text/latex": [
       "\\begin{tabular}{r|ccccc}\n",
       "\t& a & b & c & d & e\\\\\n",
       "\t\\hline\n",
       "\t& Int64 & Int64 & Int64 & Int64 & Int64\\\\\n",
       "\t\\hline\n",
       "\t1 & 1 & 1 & 1 & 1 & 1 \\\\\n",
       "\t2 & 2 & 2 & 2 & 2 & 2 \\\\\n",
       "\t3 & 3 & 3 & 3 & 3 & 3 \\\\\n",
       "\\end{tabular}\n"
      ],
      "text/plain": [
       "\u001b[1m3×5 DataFrame\u001b[0m\n",
       "\u001b[1m Row \u001b[0m│\u001b[1m a     \u001b[0m\u001b[1m b     \u001b[0m\u001b[1m c     \u001b[0m\u001b[1m d     \u001b[0m\u001b[1m e     \u001b[0m\n",
       "\u001b[1m     \u001b[0m│\u001b[90m Int64 \u001b[0m\u001b[90m Int64 \u001b[0m\u001b[90m Int64 \u001b[0m\u001b[90m Int64 \u001b[0m\u001b[90m Int64 \u001b[0m\n",
       "─────┼───────────────────────────────────\n",
       "   1 │     1      1      1      1      1\n",
       "   2 │     2      2      2      2      2\n",
       "   3 │     3      3      3      3      3"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[!, :d] .= x\n",
    "df[:, :e] .= x\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(false, false)"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.d === x, df.e === x # both copy, so in this case `!` and `:` has the same effect"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "note that in our data frame columns `:a` and `:b` store the vector `x` (not a copy)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "true"
      ]
     },
     "execution_count": 50,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.a === df.b === x"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This can lead to silent errors. For example this code leads to a bug (note that calling `pairs` on `eachcol(df)` creates an iterator of (column name, column) pairs):"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a: 3\n",
      "b: 2\n",
      "c: 3\n",
      "d: 3\n",
      "e: 3\n"
     ]
    }
   ],
   "source": [
    "for (n, c) in pairs(eachcol(df))\n",
    "    println(\"$n: \", pop!(c))\n",
    "end"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "note that for column `:b` we printed `2` as `3` was removed from it when we used `pop!` on column `:a`."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Such mistakes sometimes happen. Because of this DataFrames.jl performs consistency checks before doing an expensive operation (most notably before showing a data frame)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {},
   "outputs": [
    {
     "ename": "AssertionError",
     "evalue": "AssertionError: Data frame is corrupt: length of column :c (2) does not match length of column 1 (1). The column vector has likely been resized unintentionally (either directly or because it is shared with another data frame).",
     "output_type": "error",
     "traceback": [
      "AssertionError: Data frame is corrupt: length of column :c (2) does not match length of column 1 (1). The column vector has likely been resized unintentionally (either directly or because it is shared with another data frame).",
      "",
      "Stacktrace:",
      " [1] _check_consistency(::DataFrame) at D:\\AppData\\.julia\\packages\\DataFrames\\X0xNW\\src\\dataframe\\dataframe.jl:374",
      " [2] _show(::IOContext{Base.GenericIOBuffer{Array{UInt8,1}}}, ::DataFrame; allrows::Bool, allcols::Bool, rowlabel::Symbol, summary::Bool, eltypes::Bool, rowid::Nothing, truncate::Int64, kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at D:\\AppData\\.julia\\packages\\DataFrames\\X0xNW\\src\\abstractdataframe\\show.jl:221",
      " [3] #show#560 at D:\\AppData\\.julia\\packages\\DataFrames\\X0xNW\\src\\abstractdataframe\\show.jl:480 [inlined]",
      " [4] show(::IOContext{Base.GenericIOBuffer{Array{UInt8,1}}}, ::DataFrame) at D:\\AppData\\.julia\\packages\\DataFrames\\X0xNW\\src\\abstractdataframe\\show.jl:480",
      " [5] #show#575 at D:\\AppData\\.julia\\packages\\DataFrames\\X0xNW\\src\\abstractdataframe\\io.jl:50 [inlined]",
      " [6] show at D:\\AppData\\.julia\\packages\\DataFrames\\X0xNW\\src\\abstractdataframe\\io.jl:50 [inlined]",
      " [7] limitstringmime(::MIME{Symbol(\"text/plain\")}, ::DataFrame) at D:\\AppData\\.julia\\packages\\IJulia\\ljYVo\\src\\inline.jl:43",
      " [8] display_mimestring at D:\\AppData\\.julia\\packages\\IJulia\\ljYVo\\src\\display.jl:71 [inlined]",
      " [9] display_dict(::DataFrame) at D:\\AppData\\.julia\\packages\\IJulia\\ljYVo\\src\\display.jl:102",
      " [10] #invokelatest#1 at .\\essentials.jl:710 [inlined]",
      " [11] invokelatest at .\\essentials.jl:709 [inlined]",
      " [12] execute_request(::ZMQ.Socket, ::IJulia.Msg) at D:\\AppData\\.julia\\packages\\IJulia\\ljYVo\\src\\execute_request.jl:112",
      " [13] #invokelatest#1 at .\\essentials.jl:710 [inlined]",
      " [14] invokelatest at .\\essentials.jl:709 [inlined]",
      " [15] eventloop(::ZMQ.Socket) at D:\\AppData\\.julia\\packages\\IJulia\\ljYVo\\src\\eventloop.jl:8",
      " [16] (::IJulia.var\"#15#18\")() at .\\task.jl:356"
     ]
    }
   ],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We can investigate the columns to find out what happend:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "5-element Array{Pair{Symbol,AbstractArray{T,1} where T},1}:\n",
       " :a => [1]\n",
       " :b => [1]\n",
       " :c => [1, 2]\n",
       " :d => [1, 2]\n",
       " :e => [1, 2]"
      ]
     },
     "execution_count": 53,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "collect(pairs(eachcol(df)))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The output confirms that the data frame `df` got corrupted."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "DataFrames.jl supports a complete set of `getindex`, `getproperty`, `setindex!`, `setproperty!`, `view`, broadcasting, and broadcasting assignment operations. The details are explained here: http://juliadata.github.io/DataFrames.jl/latest/lib/indexing/."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Comparisons"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "metadata": {},
   "outputs": [],
   "source": [
    "using DataFrames"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table class=\"data-frame\"><thead><tr><th></th><th>x1</th><th>x2</th><th>x3</th></tr><tr><th></th><th>Float64</th><th>Float64</th><th>Float64</th></tr></thead><tbody><p>2 rows × 3 columns</p><tr><th>1</th><td>0.35208</td><td>0.855444</td><td>0.0661244</td></tr><tr><th>2</th><td>0.814754</td><td>0.591507</td><td>0.744025</td></tr></tbody></table>"
      ],
      "text/latex": [
       "\\begin{tabular}{r|ccc}\n",
       "\t& x1 & x2 & x3\\\\\n",
       "\t\\hline\n",
       "\t& Float64 & Float64 & Float64\\\\\n",
       "\t\\hline\n",
       "\t1 & 0.35208 & 0.855444 & 0.0661244 \\\\\n",
       "\t2 & 0.814754 & 0.591507 & 0.744025 \\\\\n",
       "\\end{tabular}\n"
      ],
      "text/plain": [
       "\u001b[1m2×3 DataFrame\u001b[0m\n",
       "\u001b[1m Row \u001b[0m│\u001b[1m x1       \u001b[0m\u001b[1m x2       \u001b[0m\u001b[1m x3        \u001b[0m\n",
       "\u001b[1m     \u001b[0m│\u001b[90m Float64  \u001b[0m\u001b[90m Float64  \u001b[0m\u001b[90m Float64   \u001b[0m\n",
       "─────┼───────────────────────────────\n",
       "   1 │ 0.35208   0.855444  0.0661244\n",
       "   2 │ 0.814754  0.591507  0.744025"
      ]
     },
     "execution_count": 55,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = DataFrame(rand(2,3), :auto)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table class=\"data-frame\"><thead><tr><th></th><th>x1</th><th>x2</th><th>x3</th></tr><tr><th></th><th>Float64</th><th>Float64</th><th>Float64</th></tr></thead><tbody><p>2 rows × 3 columns</p><tr><th>1</th><td>0.35208</td><td>0.855444</td><td>0.0661244</td></tr><tr><th>2</th><td>0.814754</td><td>0.591507</td><td>0.744025</td></tr></tbody></table>"
      ],
      "text/latex": [
       "\\begin{tabular}{r|ccc}\n",
       "\t& x1 & x2 & x3\\\\\n",
       "\t\\hline\n",
       "\t& Float64 & Float64 & Float64\\\\\n",
       "\t\\hline\n",
       "\t1 & 0.35208 & 0.855444 & 0.0661244 \\\\\n",
       "\t2 & 0.814754 & 0.591507 & 0.744025 \\\\\n",
       "\\end{tabular}\n"
      ],
      "text/plain": [
       "\u001b[1m2×3 DataFrame\u001b[0m\n",
       "\u001b[1m Row \u001b[0m│\u001b[1m x1       \u001b[0m\u001b[1m x2       \u001b[0m\u001b[1m x3        \u001b[0m\n",
       "\u001b[1m     \u001b[0m│\u001b[90m Float64  \u001b[0m\u001b[90m Float64  \u001b[0m\u001b[90m Float64   \u001b[0m\n",
       "─────┼───────────────────────────────\n",
       "   1 │ 0.35208   0.855444  0.0661244\n",
       "   2 │ 0.814754  0.591507  0.744025"
      ]
     },
     "execution_count": 56,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df2 = copy(df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "true"
      ]
     },
     "execution_count": 57,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df == df2 # compares column names and contents"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "create a minimally different data frame and use `isapprox` for comparison"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table class=\"data-frame\"><thead><tr><th></th><th>x1</th><th>x2</th><th>x3</th></tr><tr><th></th><th>Float64</th><th>Float64</th><th>Float64</th></tr></thead><tbody><p>2 rows × 3 columns</p><tr><th>1</th><td>0.35208</td><td>0.855444</td><td>0.0661244</td></tr><tr><th>2</th><td>0.814754</td><td>0.591507</td><td>0.744025</td></tr></tbody></table>"
      ],
      "text/latex": [
       "\\begin{tabular}{r|ccc}\n",
       "\t& x1 & x2 & x3\\\\\n",
       "\t\\hline\n",
       "\t& Float64 & Float64 & Float64\\\\\n",
       "\t\\hline\n",
       "\t1 & 0.35208 & 0.855444 & 0.0661244 \\\\\n",
       "\t2 & 0.814754 & 0.591507 & 0.744025 \\\\\n",
       "\\end{tabular}\n"
      ],
      "text/plain": [
       "\u001b[1m2×3 DataFrame\u001b[0m\n",
       "\u001b[1m Row \u001b[0m│\u001b[1m x1       \u001b[0m\u001b[1m x2       \u001b[0m\u001b[1m x3        \u001b[0m\n",
       "\u001b[1m     \u001b[0m│\u001b[90m Float64  \u001b[0m\u001b[90m Float64  \u001b[0m\u001b[90m Float64   \u001b[0m\n",
       "─────┼───────────────────────────────\n",
       "   1 │ 0.35208   0.855444  0.0661244\n",
       "   2 │ 0.814754  0.591507  0.744025"
      ]
     },
     "execution_count": 58,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df3 = df2 .+ eps()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "false"
      ]
     },
     "execution_count": 59,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df == df3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "true"
      ]
     },
     "execution_count": 60,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "isapprox(df, df3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "false"
      ]
     },
     "execution_count": 61,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "isapprox(df, df3, atol = eps()/2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "`missings` are handled as in Julia Base"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table class=\"data-frame\"><thead><tr><th></th><th>a</th></tr><tr><th></th><th>Missing</th></tr></thead><tbody><p>1 rows × 1 columns</p><tr><th>1</th><td><em>missing</em></td></tr></tbody></table>"
      ],
      "text/latex": [
       "\\begin{tabular}{r|c}\n",
       "\t& a\\\\\n",
       "\t\\hline\n",
       "\t& Missing\\\\\n",
       "\t\\hline\n",
       "\t1 & \\emph{missing} \\\\\n",
       "\\end{tabular}\n"
      ],
      "text/plain": [
       "\u001b[1m1×1 DataFrame\u001b[0m\n",
       "\u001b[1m Row \u001b[0m│\u001b[1m a       \u001b[0m\n",
       "\u001b[1m     \u001b[0m│\u001b[90m Missing \u001b[0m\n",
       "─────┼─────────\n",
       "   1 │\u001b[90m missing \u001b[0m"
      ]
     },
     "execution_count": 62,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = DataFrame(a=missing)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "missing"
      ]
     },
     "execution_count": 63,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df == df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "true"
      ]
     },
     "execution_count": 64,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df === df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "true"
      ]
     },
     "execution_count": 65,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "isequal(df, df)"
   ]
  }
 ],
 "metadata": {
  "@webio": {
   "lastCommId": null,
   "lastKernelId": null
  },
  "kernelspec": {
   "display_name": "Julia 1.5.3",
   "language": "julia",
   "name": "julia-1.5"
  },
  "language_info": {
   "file_extension": ".jl",
   "mimetype": "application/julia",
   "name": "julia",
   "version": "1.5.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
